From: OmariO Date: Sun, 23 Apr 2017 20:35:24 +0000 (+0300) Subject: 11106: Use RuntimeHelpers.IsReferenceOrContainsReferences in Dictionary.Remove method... X-Git-Tag: accepted/tizen/base/20180629.140029~1313 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dde35c121bc56bffd8462c0a4fc9a961a9b53b68;p=platform%2Fupstream%2Fcoreclr.git 11106: Use RuntimeHelpers.IsReferenceOrContainsReferences in Dictionary.Remove methods (#11158) --- diff --git a/src/mscorlib/src/System/Collections/Generic/Dictionary.cs b/src/mscorlib/src/System/Collections/Generic/Dictionary.cs index 7f2e2bf..e360eef 100644 --- a/src/mscorlib/src/System/Collections/Generic/Dictionary.cs +++ b/src/mscorlib/src/System/Collections/Generic/Dictionary.cs @@ -48,6 +48,7 @@ namespace System.Collections.Generic using System.Collections; using System.Diagnostics; using System.Diagnostics.Contracts; + using System.Runtime.CompilerServices; using System.Runtime.Serialization; /// @@ -614,8 +615,15 @@ namespace System.Collections.Generic } entry.hashCode = -1; entry.next = freeList; - entry.key = default(TKey); - entry.value = default(TValue); + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) + { + entry.key = default(TKey); + } + if (RuntimeHelpers.IsReferenceOrContainsReferences()) + { + entry.value = default(TValue); + } freeList = i; freeCount++; version++; @@ -664,8 +672,15 @@ namespace System.Collections.Generic entry.hashCode = -1; entry.next = freeList; - entry.key = default(TKey); - entry.value = default(TValue); + + if (RuntimeHelpers.IsReferenceOrContainsReferences()) + { + entry.key = default(TKey); + } + if (RuntimeHelpers.IsReferenceOrContainsReferences()) + { + entry.value = default(TValue); + } freeList = i; freeCount++; version++;