diff options
author | Stephen Toub <stoub@microsoft.com> | 2016-03-29 10:25:56 -0400 |
---|---|---|
committer | Stephen Toub <stoub@microsoft.com> | 2016-03-29 10:25:56 -0400 |
commit | 587cbb77129c31e93c5b5ccbe03bb6c41dc5821c (patch) | |
tree | ce667abe3d0a09906c5a275b5d06ecc0a772c05c | |
parent | e25eb2cc4e9fd8ea56364aad99c3be9f16f671d8 (diff) | |
parent | 4b5e9e6b7098cfc12506f451064e0e97c0a84ce6 (diff) | |
download | coreclr-587cbb77129c31e93c5b5ccbe03bb6c41dc5821c.tar.gz coreclr-587cbb77129c31e93c5b5ccbe03bb6c41dc5821c.tar.bz2 coreclr-587cbb77129c31e93c5b5ccbe03bb6c41dc5821c.zip |
Merge pull request #2178 from justinvp/keyedcollection_nullchecks
Remove unnecessary null checks from KeyedCollection<TKey,TItem>
-rw-r--r-- | src/mscorlib/src/System/Collections/ObjectModel/KeyedCollection.cs | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/mscorlib/src/System/Collections/ObjectModel/KeyedCollection.cs b/src/mscorlib/src/System/Collections/ObjectModel/KeyedCollection.cs index 56e9e66ef8..8ccbc3e6b5 100644 --- a/src/mscorlib/src/System/Collections/ObjectModel/KeyedCollection.cs +++ b/src/mscorlib/src/System/Collections/ObjectModel/KeyedCollection.cs @@ -80,10 +80,8 @@ namespace System.Collections.ObjectModel return dict.ContainsKey(key); } - if (key != null) { - foreach (TItem item in Items) { - if (comparer.Equals(GetKeyForItem(item), key)) return true; - } + foreach (TItem item in Items) { + if (comparer.Equals(GetKeyForItem(item), key)) return true; } return false; } @@ -115,12 +113,10 @@ namespace System.Collections.ObjectModel return false; } - if (key != null) { - for (int i = 0; i < Items.Count; i++) { - if (comparer.Equals(GetKeyForItem(Items[i]), key)) { - RemoveItem(i); - return true; - } + for (int i = 0; i < Items.Count; i++) { + if (comparer.Equals(GetKeyForItem(Items[i]), key)) { + RemoveItem(i); + return true; } } return false; |