forked from jasder/antlr
Map putIfAbsent to GetOrAdd
This commit is contained in:
parent
9a23a7f3c5
commit
8a062443af
|
@ -23,6 +23,8 @@
|
|||
-methodMapping java.util.AbstractList.addAll AddRange
|
||||
-methodMapping java.util.ArrayList.addAll AddRange
|
||||
|
||||
-methodMapping java.util.concurrent.ConcurrentMap.putIfAbsent GetOrAdd
|
||||
|
||||
-fullyQualify File
|
||||
-namespaceMapping java.lang.ref Antlr4.Runtime.Sharpen
|
||||
-namespaceMapping java.lang Antlr4.Runtime.Sharpen
|
||||
|
|
|
@ -353,7 +353,7 @@ namespace Antlr4.Runtime.Atn
|
|||
}
|
||||
if (!changed)
|
||||
{
|
||||
existing = contextCache.PutIfAbsent(context, context);
|
||||
existing = contextCache.GetOrAdd(context, context);
|
||||
visited.Put(context, existing != null ? existing : context);
|
||||
return context;
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ namespace Antlr4.Runtime.Atn
|
|||
ArrayPredictionContext arrayPredictionContext = (ArrayPredictionContext)context;
|
||||
updated = new ArrayPredictionContext(parents, arrayPredictionContext.returnStates, context.cachedHashCode);
|
||||
}
|
||||
existing = contextCache.PutIfAbsent(updated, updated);
|
||||
existing = contextCache.GetOrAdd(updated, updated);
|
||||
visited.Put(updated, existing != null ? existing : updated);
|
||||
visited.Put(context, existing != null ? existing : updated);
|
||||
return updated;
|
||||
|
|
|
@ -267,7 +267,7 @@ namespace Antlr4.Runtime.Dfa
|
|||
public virtual DFAState AddState(DFAState state)
|
||||
{
|
||||
state.stateNumber = nextStateNumber.GetAndIncrement();
|
||||
DFAState existing = states.PutIfAbsent(state, state);
|
||||
DFAState existing = states.GetOrAdd(state, state);
|
||||
if (existing != null)
|
||||
{
|
||||
return existing;
|
||||
|
|
Loading…
Reference in New Issue