Fix perf penalty for creating dictionaries the easy way. (#10855)
authorAtsushi Kanamori <AtsushiKan@users.noreply.github.com>
Mon, 10 Apr 2017 19:43:24 +0000 (12:43 -0700)
committerGitHub <noreply@github.com>
Mon, 10 Apr 2017 19:43:24 +0000 (12:43 -0700)
We went to the trouble of mitigating the perf hit
introduced by using randomized string hashing.

I assume that said perf benefit wasn't meant to be denied
to the 90% case where people use the nullary
constructor to create the Dictionary...

src/mscorlib/src/System/Collections/Generic/Dictionary.cs

index c4932f3a9b7bdacf51fdc51fbac4ac47b44e227b..6759ab2c1c511957063aa9cd6e4abe3dcd0459b9 100644 (file)
@@ -114,7 +114,7 @@ namespace System.Collections.Generic
             this.comparer = comparer ?? EqualityComparer<TKey>.Default;
 
 #if FEATURE_RANDOMIZED_STRING_HASHING
-            if (HashHelpers.s_UseRandomizedStringHashing && comparer == EqualityComparer<string>.Default)
+            if (HashHelpers.s_UseRandomizedStringHashing && this.comparer == EqualityComparer<string>.Default)
             {
                 this.comparer = (IEqualityComparer<TKey>)NonRandomizedStringEqualityComparer.Default;
             }