Performance improvement: Make ConcurrentDictionary with an Enum key also profit from...
authordnickless <daniel.hegener@gmx.net>
Tue, 3 Jan 2017 05:02:04 +0000 (00:02 -0500)
committerdnickless <daniel.hegener@gmx.net>
Tue, 3 Jan 2017 05:02:04 +0000 (00:02 -0500)
src/mscorlib/src/System/Collections/Concurrent/ConcurrentDictionary.cs

index c1a6f75..9ef1544 100644 (file)
@@ -104,6 +104,10 @@ namespace System.Collections.Concurrent
         private static bool IsValueWriteAtomic()
         {
             Type valueType = typeof(TValue);
+            if (valueType.IsEnum)
+            {
+                valueType = Enum.GetUnderlyingType(valueType);
+            }
 
             //
             // Section 12.6.6 of ECMA CLI explains which types can be read and written atomically without