From 4d8b7aca399f1e14b0a1ee6c02c0a613a8c931d1 Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Thu, 7 Dec 2017 20:21:48 +0000 Subject: [PATCH] fixes --- .../shared/System/Collections/Generic/Dictionary.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mscorlib/shared/System/Collections/Generic/Dictionary.cs b/src/mscorlib/shared/System/Collections/Generic/Dictionary.cs index 09434e6f54b2..cf35cdf9ebb7 100644 --- a/src/mscorlib/shared/System/Collections/Generic/Dictionary.cs +++ b/src/mscorlib/shared/System/Collections/Generic/Dictionary.cs @@ -77,7 +77,7 @@ public Dictionary(int capacity, IEqualityComparer comparer) this.comparer = comparer; } - if (typeof(TKey) == typeof(string) && comparer == null) + if (typeof(TKey) == typeof(string) && this.comparer == null) { // To start, move off default comparer for string which is randomised this.comparer = (IEqualityComparer)NonRandomizedStringEqualityComparer.Default; @@ -283,7 +283,7 @@ public bool ContainsValue(TValue value) { for (int i = 0; i < count; i++) { - if (entries[i].hashCode >= 0 && (default(TValue) == null ? value.Equals(entries[i].value) : EqualityComparer.Default.Equals(entries[i].value, value))) return true; + if (entries[i].hashCode >= 0 && EqualityComparer.Default.Equals(entries[i].value, value)) return true; } } return false; @@ -358,7 +358,7 @@ private int FindEntry(TKey key) int hashCode = (comparer != null ? comparer.GetHashCode(key) : key.GetHashCode()) & 0x7FFFFFFF; for (int i = buckets[hashCode % buckets.Length]; i >= 0; i = entries[i].next) { - if (entries[i].hashCode == hashCode && (comparer != null ? comparer.Equals(entries[i].key, key) : (default(TKey) == null ? key.Equals(entries[i].key) : EqualityComparer.Default.Equals(entries[i].key, key)))) return i; + if (entries[i].hashCode == hashCode && (comparer != null ? comparer.Equals(entries[i].key, key) : EqualityComparer.Default.Equals(entries[i].key, key))) return i; } } return -1; @@ -387,7 +387,7 @@ private bool TryInsert(TKey key, TValue value, InsertionBehavior behavior) for (int i = buckets[targetBucket]; i >= 0; i = entries[i].next) { - if (entries[i].hashCode == hashCode && (comparer != null ? comparer.Equals(entries[i].key, key) : (default(TKey) == null ? key.Equals(entries[i].key) : EqualityComparer.Default.Equals(entries[i].key, key)))) + if (entries[i].hashCode == hashCode && (comparer != null ? comparer.Equals(entries[i].key, key) : EqualityComparer.Default.Equals(entries[i].key, key))) { if (behavior == InsertionBehavior.OverwriteExisting) { @@ -550,7 +550,7 @@ public bool Remove(TKey key) { ref Entry entry = ref entries[i]; - if (entry.hashCode == hashCode && (comparer != null ? comparer.Equals(entry.key, key) : (default(TKey) == null ? key.Equals(entry.key) : EqualityComparer.Default.Equals(entry.key, key)))) + if (entry.hashCode == hashCode && (comparer != null ? comparer.Equals(entry.key, key) : EqualityComparer.Default.Equals(entry.key, key))) { if (last < 0) { @@ -604,7 +604,7 @@ public bool Remove(TKey key, out TValue value) { ref Entry entry = ref entries[i]; - if (entry.hashCode == hashCode && (comparer != null ? comparer.Equals(entry.key, key) : (default(TKey) == null ? key.Equals(entry.key) : EqualityComparer.Default.Equals(entry.key, key)))) + if (entry.hashCode == hashCode && (comparer != null ? comparer.Equals(entry.key, key) : EqualityComparer.Default.Equals(entry.key, key))) { if (last < 0) {