From e9c53a9f2a91e33e9635cc3ce320f1205ed4d2a4 Mon Sep 17 00:00:00 2001 From: Ilya Date: Sat, 1 Sep 2018 01:57:19 +0500 Subject: [PATCH] Optimize RemoveAt() method in OrderedDictionary class (dotnet/corefx#32044) Commit migrated from https://github.com/dotnet/corefx/commit/243e24c32fd587f046b23b9770fb811c962aaeed --- .../src/System/Collections/Specialized/OrderedDictionary.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/OrderedDictionary.cs b/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/OrderedDictionary.cs index 1736bc4..efc32cf 100644 --- a/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/OrderedDictionary.cs +++ b/src/libraries/System.Collections.Specialized/src/System/Collections/Specialized/OrderedDictionary.cs @@ -367,8 +367,8 @@ namespace System.Collections.Specialized { throw new ArgumentOutOfRangeException(nameof(index)); } - EnsureObjectsTable(); - EnsureObjectsArray(); + // The 'index >= Count' check above ensures + // that the '_objectsArray' and '_objectsTable' objects are initialized. object key = ((DictionaryEntry)_objectsArray[index]).Key; _objectsArray.RemoveAt(index); _objectsTable.Remove(key); -- 2.7.4