mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-03-10 00:23:29 +08:00
make operator token threadsafe #97
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
internal class OperatorToken : IDataToken<string>
|
||||
{
|
||||
private static readonly object Lock = new object();
|
||||
private static readonly Dictionary<string, string> PooledNames = new Dictionary<string, string>();
|
||||
|
||||
public static readonly OperatorToken R = new OperatorToken("R");
|
||||
@@ -24,10 +25,15 @@
|
||||
|
||||
private OperatorToken(string data)
|
||||
{
|
||||
if (!PooledNames.TryGetValue(data, out var stored))
|
||||
string stored;
|
||||
|
||||
lock (Lock)
|
||||
{
|
||||
stored = data;
|
||||
PooledNames[data] = stored;
|
||||
if (!PooledNames.TryGetValue(data, out stored))
|
||||
{
|
||||
stored = data;
|
||||
PooledNames[data] = stored;
|
||||
}
|
||||
}
|
||||
|
||||
Data = stored;
|
||||
|
||||
Reference in New Issue
Block a user