Fix perf penalty for creating dictionaries the easy way. (dotnet/coreclr#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...

Commit migrated from https://github.com/dotnet/coreclr/commit/6c42a52b01960d7689c93398caa06ca5f79e903f

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

index c4932f3..6759ab2 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;
             }