From 040896b40a83b38194fc2f5ed87edc1a6f6c813f Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Tue, 19 Feb 2013 11:39:49 -0600 Subject: [PATCH] Updated ConcurrentDictionary usage in PredictionContext --- Antlr4.Runtime/Atn/PredictionContext.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Antlr4.Runtime/Atn/PredictionContext.cs b/Antlr4.Runtime/Atn/PredictionContext.cs index b25bdc996..aac5999fd 100644 --- a/Antlr4.Runtime/Atn/PredictionContext.cs +++ b/Antlr4.Runtime/Atn/PredictionContext.cs @@ -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; }