forked from jasder/antlr
Updated ConcurrentDictionary usage in PredictionContext
This commit is contained in:
parent
dbdec984e2
commit
040896b40a
|
@ -381,8 +381,8 @@ namespace Antlr4.Runtime.Atn
|
||||||
}
|
}
|
||||||
if (!changed)
|
if (!changed)
|
||||||
{
|
{
|
||||||
existing = contextCache.PutIfAbsent(context, context);
|
existing = contextCache.GetOrAdd(context, context);
|
||||||
visited.Put(context, existing != null ? existing : context);
|
visited.Put(context, existing);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
// We know parents.length>0 because context.isEmpty() is checked at the beginning of the method.
|
// We know parents.length>0 because context.isEmpty() is checked at the beginning of the method.
|
||||||
|
@ -397,9 +397,9 @@ namespace Antlr4.Runtime.Atn
|
||||||
updated = new ArrayPredictionContext(parents, arrayPredictionContext.returnStates
|
updated = new ArrayPredictionContext(parents, arrayPredictionContext.returnStates
|
||||||
, context.cachedHashCode);
|
, context.cachedHashCode);
|
||||||
}
|
}
|
||||||
existing = contextCache.PutIfAbsent(updated, updated);
|
existing = contextCache.GetOrAdd(updated, updated);
|
||||||
visited.Put(updated, existing != null ? existing : updated);
|
visited.Put(updated, existing);
|
||||||
visited.Put(context, existing != null ? existing : updated);
|
visited.Put(context, existing);
|
||||||
return updated;
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue