Updated ConcurrentDictionary usage in PredictionContext

This commit is contained in:
Sam Harwell 2013-02-19 11:39:49 -06:00
parent dbdec984e2
commit 040896b40a
1 changed files with 5 additions and 5 deletions

View File

@ -381,8 +381,8 @@ namespace Antlr4.Runtime.Atn
}
if (!changed)
{
existing = contextCache.PutIfAbsent(context, context);
visited.Put(context, existing != null ? existing : context);
existing = contextCache.GetOrAdd(context, context);
visited.Put(context, existing);
return context;
}
// 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
, context.cachedHashCode);
}
existing = contextCache.PutIfAbsent(updated, updated);
visited.Put(updated, existing != null ? existing : updated);
visited.Put(context, existing != null ? existing : updated);
existing = contextCache.GetOrAdd(updated, updated);
visited.Put(updated, existing);
visited.Put(context, existing);
return updated;
}