From: Ben Adams Date: Mon, 11 Dec 2017 15:02:20 +0000 (+0000) Subject: Dictionary Initalize CQ (#15461) X-Git-Tag: accepted/tizen/base/20180629.140029~367 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7e84010dafaec33b7eabe1d07fc7bdf40704c577;p=platform%2Fupstream%2Fcoreclr.git Dictionary Initalize CQ (#15461) --- diff --git a/src/mscorlib/shared/System/Collections/Generic/Dictionary.cs b/src/mscorlib/shared/System/Collections/Generic/Dictionary.cs index 6bd0785..4f34275 100644 --- a/src/mscorlib/shared/System/Collections/Generic/Dictionary.cs +++ b/src/mscorlib/shared/System/Collections/Generic/Dictionary.cs @@ -376,10 +376,15 @@ namespace System.Collections.Generic private void Initialize(int capacity) { int size = HashHelpers.GetPrime(capacity); - _buckets = new int[size]; - for (int i = 0; i < _buckets.Length; i++) _buckets[i] = -1; - _entries = new Entry[size]; + int[] buckets = new int[size]; + for (int i = 0; i < buckets.Length; i++) + { + buckets[i] = -1; + } + _freeList = -1; + _buckets = buckets; + _entries = new Entry[size]; } private bool TryInsert(TKey key, TValue value, InsertionBehavior behavior) @@ -470,10 +475,7 @@ namespace System.Collections.Generic if (hashsize != 0) { - _buckets = new int[hashsize]; - for (int i = 0; i < _buckets.Length; i++) _buckets[i] = -1; - _entries = new Entry[hashsize]; - _freeList = -1; + Initialize(hashsize); KeyValuePair[] array = (KeyValuePair[]) siInfo.GetValue(KeyValuePairsName, typeof(KeyValuePair[]));