You've already forked linux-packaging-mono
Imported Upstream version 4.3.2.467
Former-commit-id: 9c2cb47f45fa221e661ab616387c9cda183f283d
This commit is contained in:
@@ -139,6 +139,13 @@ namespace System.Collections.Generic
|
||||
comparer = Comparer<T>.Default;
|
||||
}
|
||||
|
||||
#if FEATURE_CORECLR
|
||||
// Since QuickSort and IntrospectiveSort produce different sorting sequence for equal keys the upgrade
|
||||
// to IntrospectiveSort was quirked. However since the phone builds always shipped with the new sort aka
|
||||
// IntrospectiveSort and we would want to continue using this sort moving forward CoreCLR always uses the new sort.
|
||||
|
||||
IntrospectiveSort(keys, index, length, comparer);
|
||||
#else
|
||||
if (BinaryCompatibility.TargetsAtLeast_Desktop_V4_5)
|
||||
{
|
||||
IntrospectiveSort(keys, index, length, comparer);
|
||||
@@ -147,6 +154,7 @@ namespace System.Collections.Generic
|
||||
{
|
||||
DepthLimitedQuickSort(keys, index, length + index - 1, comparer, IntrospectiveSortUtilities.QuickSortDepthThreshold);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
catch (IndexOutOfRangeException)
|
||||
{
|
||||
@@ -473,6 +481,14 @@ namespace System.Collections.Generic
|
||||
#else
|
||||
if (comparer == null || comparer == Comparer<T>.Default) {
|
||||
#endif
|
||||
|
||||
#if FEATURE_CORECLR
|
||||
// Since QuickSort and IntrospectiveSort produce different sorting sequence for equal keys the upgrade
|
||||
// to IntrospectiveSort was quirked. However since the phone builds always shipped with the new sort aka
|
||||
// IntrospectiveSort and we would want to continue using this sort moving forward CoreCLR always uses the new sort.
|
||||
|
||||
IntrospectiveSort(keys, index, length);
|
||||
#else
|
||||
// call the faster version of our sort algorithm if the user doesn't provide a comparer
|
||||
if (BinaryCompatibility.TargetsAtLeast_Desktop_V4_5)
|
||||
{
|
||||
@@ -482,9 +498,17 @@ namespace System.Collections.Generic
|
||||
{
|
||||
DepthLimitedQuickSort(keys, index, length + index - 1, IntrospectiveSortUtilities.QuickSortDepthThreshold);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if FEATURE_CORECLR
|
||||
// Since QuickSort and IntrospectiveSort produce different sorting sequence for equal keys the upgrade
|
||||
// to IntrospectiveSort was quirked. However since the phone builds always shipped with the new sort aka
|
||||
// IntrospectiveSort and we would want to continue using this sort moving forward CoreCLR always uses the new sort.
|
||||
|
||||
ArraySortHelper<T>.IntrospectiveSort(keys, index, length, comparer);
|
||||
#else
|
||||
if (BinaryCompatibility.TargetsAtLeast_Desktop_V4_5)
|
||||
{
|
||||
ArraySortHelper<T>.IntrospectiveSort(keys, index, length, comparer);
|
||||
@@ -493,6 +517,7 @@ namespace System.Collections.Generic
|
||||
{
|
||||
ArraySortHelper<T>.DepthLimitedQuickSort(keys, index, length + index - 1, comparer, IntrospectiveSortUtilities.QuickSortDepthThreshold);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
catch (IndexOutOfRangeException)
|
||||
@@ -890,6 +915,13 @@ namespace System.Collections.Generic
|
||||
comparer = Comparer<TKey>.Default;
|
||||
}
|
||||
|
||||
#if FEATURE_CORECLR
|
||||
// Since QuickSort and IntrospectiveSort produce different sorting sequence for equal keys the upgrade
|
||||
// to IntrospectiveSort was quirked. However since the phone builds always shipped with the new sort aka
|
||||
// IntrospectiveSort and we would want to continue using this sort moving forward CoreCLR always uses the new sort.
|
||||
|
||||
IntrospectiveSort(keys, values, index, length, comparer);
|
||||
#else
|
||||
if (BinaryCompatibility.TargetsAtLeast_Desktop_V4_5)
|
||||
{
|
||||
IntrospectiveSort(keys, values, index, length, comparer);
|
||||
@@ -898,6 +930,7 @@ namespace System.Collections.Generic
|
||||
{
|
||||
DepthLimitedQuickSort(keys, values, index, length + index - 1, comparer, IntrospectiveSortUtilities.QuickSortDepthThreshold);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
catch (IndexOutOfRangeException)
|
||||
{
|
||||
@@ -1211,6 +1244,13 @@ namespace System.Collections.Generic
|
||||
{
|
||||
if (comparer == null || comparer == Comparer<TKey>.Default)
|
||||
{
|
||||
#if FEATURE_CORECLR
|
||||
// Since QuickSort and IntrospectiveSort produce different sorting sequence for equal keys the upgrade
|
||||
// to IntrospectiveSort was quirked. However since the phone builds always shipped with the new sort aka
|
||||
// IntrospectiveSort and we would want to continue using this sort moving forward CoreCLR always uses the new sort.
|
||||
|
||||
IntrospectiveSort(keys, values, index, length);
|
||||
#else
|
||||
// call the faster version of our sort algorithm if the user doesn't provide a comparer
|
||||
if (BinaryCompatibility.TargetsAtLeast_Desktop_V4_5)
|
||||
{
|
||||
@@ -1220,9 +1260,17 @@ namespace System.Collections.Generic
|
||||
{
|
||||
DepthLimitedQuickSort(keys, values, index, length + index - 1, IntrospectiveSortUtilities.QuickSortDepthThreshold);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if FEATURE_CORECLR
|
||||
// Since QuickSort and IntrospectiveSort produce different sorting sequence for equal keys the upgrade
|
||||
// to IntrospectiveSort was quirked. However since the phone builds always shipped with the new sort aka
|
||||
// IntrospectiveSort and we would want to continue using this sort moving forward CoreCLR always uses the new sort.
|
||||
|
||||
ArraySortHelper<TKey, TValue>.IntrospectiveSort(keys, values, index, length, comparer);
|
||||
#else
|
||||
if (BinaryCompatibility.TargetsAtLeast_Desktop_V4_5)
|
||||
{
|
||||
ArraySortHelper<TKey, TValue>.IntrospectiveSort(keys, values, index, length, comparer);
|
||||
@@ -1231,6 +1279,7 @@ namespace System.Collections.Generic
|
||||
{
|
||||
ArraySortHelper<TKey, TValue>.DepthLimitedQuickSort(keys, values, index, length + index - 1, comparer, IntrospectiveSortUtilities.QuickSortDepthThreshold);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -92,6 +92,13 @@ namespace System.Collections.Generic {
|
||||
if (capacity < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.capacity);
|
||||
if (capacity > 0) Initialize(capacity);
|
||||
this.comparer = comparer ?? EqualityComparer<TKey>.Default;
|
||||
|
||||
#if FEATURE_CORECLR
|
||||
if (HashHelpers.s_UseRandomizedStringHashing && comparer == EqualityComparer<string>.Default)
|
||||
{
|
||||
this.comparer = (IEqualityComparer<TKey>) NonRandomizedStringEqualityComparer.Default;
|
||||
}
|
||||
#endif // FEATURE_CORECLR
|
||||
}
|
||||
|
||||
public Dictionary(IDictionary<TKey,TValue> dictionary): this(dictionary, null) {}
|
||||
@@ -361,11 +368,26 @@ namespace System.Collections.Generic {
|
||||
version++;
|
||||
|
||||
#if FEATURE_RANDOMIZED_STRING_HASHING
|
||||
|
||||
#if FEATURE_CORECLR
|
||||
// In case we hit the collision threshold we'll need to switch to the comparer which is using randomized string hashing
|
||||
// in this case will be EqualityComparer<string>.Default.
|
||||
// Note, randomized string hashing is turned on by default on coreclr so EqualityComparer<string>.Default will
|
||||
// be using randomized string hashing
|
||||
|
||||
if (collisionCount > HashHelpers.HashCollisionThreshold && comparer == NonRandomizedStringEqualityComparer.Default)
|
||||
{
|
||||
comparer = (IEqualityComparer<TKey>) EqualityComparer<string>.Default;
|
||||
Resize(entries.Length, true);
|
||||
}
|
||||
#else
|
||||
if(collisionCount > HashHelpers.HashCollisionThreshold && HashHelpers.IsWellKnownEqualityComparer(comparer))
|
||||
{
|
||||
comparer = (IEqualityComparer<TKey>) HashHelpers.GetRandomizedEqualityComparer(comparer);
|
||||
Resize(entries.Length, true);
|
||||
}
|
||||
#endif // FEATURE_CORECLR
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -776,7 +798,7 @@ namespace System.Collections.Generic {
|
||||
[DebuggerTypeProxy(typeof(Mscorlib_DictionaryKeyCollectionDebugView<,>))]
|
||||
[DebuggerDisplay("Count = {Count}")]
|
||||
[Serializable]
|
||||
public sealed class KeyCollection: ICollection<TKey>, ICollection
|
||||
public sealed class KeyCollection: ICollection<TKey>, ICollection, IReadOnlyCollection<TKey>
|
||||
{
|
||||
private Dictionary<TKey,TValue> dictionary;
|
||||
|
||||
@@ -963,7 +985,7 @@ namespace System.Collections.Generic {
|
||||
[DebuggerTypeProxy(typeof(Mscorlib_DictionaryValueCollectionDebugView<,>))]
|
||||
[DebuggerDisplay("Count = {Count}")]
|
||||
[Serializable]
|
||||
public sealed class ValueCollection: ICollection<TValue>, ICollection
|
||||
public sealed class ValueCollection: ICollection<TValue>, ICollection, IReadOnlyCollection<TValue>
|
||||
{
|
||||
private Dictionary<TKey,TValue> dictionary;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Security;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace System.Collections.Generic
|
||||
{
|
||||
@@ -25,9 +26,6 @@ namespace System.Collections.Generic
|
||||
static volatile EqualityComparer<T> defaultComparer;
|
||||
|
||||
public static EqualityComparer<T> Default {
|
||||
#if !FEATURE_CORECLR
|
||||
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
|
||||
#endif
|
||||
get {
|
||||
Contract.Ensures(Contract.Result<EqualityComparer<T>>() != null);
|
||||
|
||||
@@ -79,15 +77,44 @@ namespace System.Collections.Generic
|
||||
#endif
|
||||
}
|
||||
}
|
||||
// If T is an int-based Enum, return an EnumEqualityComparer<T>
|
||||
|
||||
// See the METHOD__JIT_HELPERS__UNSAFE_ENUM_CAST and METHOD__JIT_HELPERS__UNSAFE_ENUM_CAST_LONG cases in getILIntrinsicImplementation
|
||||
if (t.IsEnum && Enum.GetUnderlyingType(t) == typeof(int))
|
||||
{
|
||||
if (t.IsEnum) {
|
||||
TypeCode underlyingTypeCode = Type.GetTypeCode(Enum.GetUnderlyingType(t));
|
||||
|
||||
// Depending on the enum type, we need to special case the comparers so that we avoid boxing
|
||||
// Note: We have different comparers for Short and SByte because for those types we need to make sure we call GetHashCode on the actual underlying type as the
|
||||
// implementation of GetHashCode is more complex than for the other types.
|
||||
switch (underlyingTypeCode) {
|
||||
case TypeCode.Int16: // short
|
||||
#if MONO
|
||||
return (EqualityComparer<T>)RuntimeType.CreateInstanceForAnotherGenericParameter (typeof(EnumEqualityComparer<>), t);
|
||||
return (EqualityComparer<T>)RuntimeType.CreateInstanceForAnotherGenericParameter (typeof(ShortEnumEqualityComparer<>), t);
|
||||
#else
|
||||
return (EqualityComparer<T>)RuntimeTypeHandle.CreateInstanceForAnotherGenericParameter((RuntimeType)typeof(EnumEqualityComparer<int>), t);
|
||||
return (EqualityComparer<T>)RuntimeTypeHandle.CreateInstanceForAnotherGenericParameter((RuntimeType)typeof(ShortEnumEqualityComparer<short>), t);
|
||||
#endif
|
||||
case TypeCode.SByte:
|
||||
#if MONO
|
||||
return (EqualityComparer<T>)RuntimeType.CreateInstanceForAnotherGenericParameter (typeof(SByteEnumEqualityComparer<>), t);
|
||||
#else
|
||||
return (EqualityComparer<T>)RuntimeTypeHandle.CreateInstanceForAnotherGenericParameter((RuntimeType)typeof(SByteEnumEqualityComparer<sbyte>), t);
|
||||
#endif
|
||||
case TypeCode.Int32:
|
||||
case TypeCode.UInt32:
|
||||
case TypeCode.Byte:
|
||||
case TypeCode.UInt16: //ushort
|
||||
#if MONO
|
||||
return (EqualityComparer<T>)RuntimeType.CreateInstanceForAnotherGenericParameter (typeof(EnumEqualityComparer<>), t);
|
||||
#else
|
||||
return (EqualityComparer<T>)RuntimeTypeHandle.CreateInstanceForAnotherGenericParameter((RuntimeType)typeof(EnumEqualityComparer<int>), t);
|
||||
#endif
|
||||
case TypeCode.Int64:
|
||||
case TypeCode.UInt64:
|
||||
#if MONO
|
||||
return (EqualityComparer<T>)RuntimeType.CreateInstanceForAnotherGenericParameter (typeof(LongEnumEqualityComparer<>), t);
|
||||
#else
|
||||
return (EqualityComparer<T>)RuntimeTypeHandle.CreateInstanceForAnotherGenericParameter((RuntimeType)typeof(LongEnumEqualityComparer<long>), t);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
// Otherwise return an ObjectEqualityComparer<T>
|
||||
return new ObjectEqualityComparer<T>();
|
||||
@@ -146,9 +173,6 @@ namespace System.Collections.Generic
|
||||
}
|
||||
|
||||
[Pure]
|
||||
#if !FEATURE_CORECLR
|
||||
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
|
||||
#endif
|
||||
public override int GetHashCode(T obj) {
|
||||
if (obj == null) return 0;
|
||||
return obj.GetHashCode();
|
||||
@@ -268,9 +292,6 @@ namespace System.Collections.Generic
|
||||
}
|
||||
|
||||
[Pure]
|
||||
#if !FEATURE_CORECLR
|
||||
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
|
||||
#endif
|
||||
public override int GetHashCode(T obj) {
|
||||
if (obj == null) return 0;
|
||||
return obj.GetHashCode();
|
||||
@@ -317,6 +338,34 @@ namespace System.Collections.Generic
|
||||
}
|
||||
}
|
||||
|
||||
#if FEATURE_CORECLR
|
||||
// NonRandomizedStringEqualityComparer is the comparer used by default with the Dictionary<string,...>
|
||||
// As the randomized string hashing is turned on by default on coreclr, we need to keep the performance not affected
|
||||
// as much as possible in the main stream scenarios like Dictionary<string,…>
|
||||
// We use NonRandomizedStringEqualityComparer as default comparer as it doesn’t use the randomized string hashing which
|
||||
// keep the perofrmance not affected till we hit collision threshold and then we switch to the comparer which is using
|
||||
// randomized string hashing GenericEqualityComparer<string>
|
||||
|
||||
internal class NonRandomizedStringEqualityComparer : GenericEqualityComparer<string> {
|
||||
static IEqualityComparer<string> s_nonRandomizedComparer;
|
||||
|
||||
internal static IEqualityComparer<string> Default {
|
||||
get {
|
||||
if (s_nonRandomizedComparer == null) {
|
||||
s_nonRandomizedComparer = new NonRandomizedStringEqualityComparer();
|
||||
}
|
||||
return s_nonRandomizedComparer;
|
||||
}
|
||||
}
|
||||
|
||||
[Pure]
|
||||
public override int GetHashCode(string obj) {
|
||||
if (obj == null) return 0;
|
||||
return obj.GetLegacyNonRandomizedHashCode();
|
||||
}
|
||||
}
|
||||
#endif // FEATURE_CORECLR
|
||||
|
||||
// Performance of IndexOf on byte array is very important for some scenarios.
|
||||
// We will call the C runtime function memchr, which is optimized.
|
||||
[Serializable]
|
||||
@@ -366,11 +415,10 @@ namespace System.Collections.Generic
|
||||
public override int GetHashCode() {
|
||||
return this.GetType().Name.GetHashCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
internal sealed class EnumEqualityComparer<T>: EqualityComparer<T> where T : struct
|
||||
internal class EnumEqualityComparer<T> : EqualityComparer<T>, ISerializable where T : struct
|
||||
{
|
||||
[Pure]
|
||||
public override bool Equals(T x, T y) {
|
||||
@@ -385,6 +433,19 @@ namespace System.Collections.Generic
|
||||
return x_final.GetHashCode();
|
||||
}
|
||||
|
||||
public EnumEqualityComparer() { }
|
||||
|
||||
// This is used by the serialization engine.
|
||||
protected EnumEqualityComparer(SerializationInfo information, StreamingContext context) { }
|
||||
|
||||
[SecurityCritical]
|
||||
public void GetObjectData(SerializationInfo info, StreamingContext context) {
|
||||
// For back-compat we need to serialize the comparers for enums with underlying types other than int as ObjectEqualityComparer
|
||||
if (Type.GetTypeCode(Enum.GetUnderlyingType(typeof(T))) != TypeCode.Int32) {
|
||||
info.SetType(typeof(ObjectEqualityComparer<T>));
|
||||
}
|
||||
}
|
||||
|
||||
// Equals method for the comparer itself.
|
||||
public override bool Equals(Object obj){
|
||||
EnumEqualityComparer<T> comparer = obj as EnumEqualityComparer<T>;
|
||||
@@ -397,7 +458,37 @@ namespace System.Collections.Generic
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
internal sealed class LongEnumEqualityComparer<T>: EqualityComparer<T> where T : struct
|
||||
internal sealed class SByteEnumEqualityComparer<T> : EnumEqualityComparer<T>, ISerializable where T : struct
|
||||
{
|
||||
public SByteEnumEqualityComparer() { }
|
||||
|
||||
// This is used by the serialization engine.
|
||||
public SByteEnumEqualityComparer(SerializationInfo information, StreamingContext context) { }
|
||||
|
||||
[Pure]
|
||||
public override int GetHashCode(T obj) {
|
||||
int x_final = System.Runtime.CompilerServices.JitHelpers.UnsafeEnumCast(obj);
|
||||
return ((sbyte)x_final).GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
internal sealed class ShortEnumEqualityComparer<T> : EnumEqualityComparer<T>, ISerializable where T : struct
|
||||
{
|
||||
public ShortEnumEqualityComparer() { }
|
||||
|
||||
// This is used by the serialization engine.
|
||||
public ShortEnumEqualityComparer(SerializationInfo information, StreamingContext context) { }
|
||||
|
||||
[Pure]
|
||||
public override int GetHashCode(T obj) {
|
||||
int x_final = System.Runtime.CompilerServices.JitHelpers.UnsafeEnumCast(obj);
|
||||
return ((short)x_final).GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
internal sealed class LongEnumEqualityComparer<T> : EqualityComparer<T>, ISerializable where T : struct
|
||||
{
|
||||
[Pure]
|
||||
public override bool Equals(T x, T y) {
|
||||
@@ -421,6 +512,19 @@ namespace System.Collections.Generic
|
||||
public override int GetHashCode() {
|
||||
return this.GetType().Name.GetHashCode();
|
||||
}
|
||||
|
||||
public LongEnumEqualityComparer() { }
|
||||
|
||||
// This is used by the serialization engine.
|
||||
public LongEnumEqualityComparer(SerializationInfo information, StreamingContext context) { }
|
||||
|
||||
[SecurityCritical]
|
||||
public void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
// The LongEnumEqualityComparer does not exist on 4.0 so we need to serialize this comparer as ObjectEqualityComparer
|
||||
// to allow for roundtrip between 4.0 and 4.5.
|
||||
info.SetType(typeof(ObjectEqualityComparer<T>));
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
**
|
||||
** Interface: ICollection
|
||||
**
|
||||
** <OWNER>[....]</OWNER>
|
||||
** <OWNER>kimhamil</OWNER>
|
||||
**
|
||||
**
|
||||
** Purpose: Base interface for all generic collections.
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
**
|
||||
** Interface: IComparer
|
||||
**
|
||||
** <OWNER>[....]</OWNER>
|
||||
** <OWNER>kimhamil</OWNER>
|
||||
**
|
||||
**
|
||||
** Purpose: Interface for comparing two generic Objects.
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
**
|
||||
** Interface: IDictionary
|
||||
**
|
||||
** <OWNER>[....]</OWNER>
|
||||
** <OWNER>kimhamil</OWNER>
|
||||
**
|
||||
**
|
||||
** Purpose: Base interface for all generic dictionaries.
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
**
|
||||
** Interface: IEnumerable
|
||||
**
|
||||
** <OWNER>[....]</OWNER>
|
||||
** <OWNER>kimhamil</OWNER>
|
||||
**
|
||||
**
|
||||
** Purpose: Interface for providing generic IEnumerators
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
**
|
||||
** Interface: IEnumerator
|
||||
**
|
||||
** <OWNER>[....]</OWNER>
|
||||
** <OWNER>kimhamil</OWNER>
|
||||
**
|
||||
**
|
||||
** Purpose: Base interface for all generic enumerators.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// ==--==
|
||||
// <OWNER>[....]</OWNER>
|
||||
// <OWNER>kimhamil</OWNER>
|
||||
//
|
||||
|
||||
namespace System.Collections.Generic {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
**
|
||||
** Interface: IList
|
||||
**
|
||||
** <OWNER>[....]</OWNER>
|
||||
** <OWNER>kimhamil</OWNER>
|
||||
**
|
||||
**
|
||||
** Purpose: Base interface for all generic lists.
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
**
|
||||
** Interface: IReadOnlyCollection<T>
|
||||
**
|
||||
** <OWNER>[....]</OWNER>
|
||||
** <OWNER>matell</OWNER>
|
||||
**
|
||||
** Purpose: Base interface for read-only generic lists.
|
||||
**
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
**
|
||||
** Interface: IReadOnlyDictionary<TKey, TValue>
|
||||
**
|
||||
** <OWNER>[....]</OWNER>
|
||||
** <OWNER>matell</OWNER>
|
||||
**
|
||||
** Purpose: Base interface for read-only generic dictionaries.
|
||||
**
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
**
|
||||
** Interface: IReadOnlyList<T>
|
||||
**
|
||||
** <OWNER>[....]</OWNER>
|
||||
** <OWNER>matell</OWNER>
|
||||
**
|
||||
** Purpose: Base interface for read-only generic lists.
|
||||
**
|
||||
|
||||
@@ -49,9 +49,6 @@ namespace System.Collections.Generic {
|
||||
// Constructs a List. The list is initially empty and has a capacity
|
||||
// of zero. Upon adding the first element to the list the capacity is
|
||||
// increased to 16, and then increased in multiples of two as required.
|
||||
#if !FEATURE_CORECLR
|
||||
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
|
||||
#endif
|
||||
public List() {
|
||||
_items = _emptyArray;
|
||||
}
|
||||
@@ -60,9 +57,6 @@ namespace System.Collections.Generic {
|
||||
// initially empty, but will have room for the given number of elements
|
||||
// before any reallocations are required.
|
||||
//
|
||||
#if !FEATURE_CORECLR
|
||||
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
|
||||
#endif
|
||||
public List(int capacity) {
|
||||
if (capacity < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.capacity, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
|
||||
Contract.EndContractBlock();
|
||||
@@ -114,9 +108,6 @@ namespace System.Collections.Generic {
|
||||
// array of the list is reallocated to the given capacity.
|
||||
//
|
||||
public int Capacity {
|
||||
#if !FEATURE_CORECLR
|
||||
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
|
||||
#endif
|
||||
get {
|
||||
Contract.Ensures(Contract.Result<int>() >= 0);
|
||||
return _items.Length;
|
||||
@@ -157,16 +148,10 @@ namespace System.Collections.Generic {
|
||||
|
||||
// Is this List read-only?
|
||||
bool ICollection<T>.IsReadOnly {
|
||||
#if !FEATURE_CORECLR
|
||||
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
|
||||
#endif
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
bool System.Collections.IList.IsReadOnly {
|
||||
#if !FEATURE_CORECLR
|
||||
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
|
||||
#endif
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
@@ -187,9 +172,6 @@ namespace System.Collections.Generic {
|
||||
// Sets or Gets the element at the given index.
|
||||
//
|
||||
public T this[int index] {
|
||||
#if !FEATURE_CORECLR
|
||||
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
|
||||
#endif
|
||||
#if MONO
|
||||
[System.Runtime.CompilerServices.MethodImpl (System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
@@ -206,9 +188,6 @@ namespace System.Collections.Generic {
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !FEATURE_CORECLR
|
||||
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
|
||||
#endif
|
||||
set {
|
||||
if ((uint) index >= (uint)_size) {
|
||||
ThrowHelper.ThrowArgumentOutOfRangeException();
|
||||
@@ -385,9 +364,6 @@ namespace System.Collections.Generic {
|
||||
// Copies this List into array, which must be of a
|
||||
// compatible array type.
|
||||
//
|
||||
#if !FEATURE_CORECLR
|
||||
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
|
||||
#endif
|
||||
public void CopyTo(T[] array) {
|
||||
CopyTo(array, 0);
|
||||
}
|
||||
@@ -395,9 +371,6 @@ namespace System.Collections.Generic {
|
||||
// Copies this List into array, which must be of a
|
||||
// compatible array type.
|
||||
//
|
||||
#if !FEATURE_CORECLR
|
||||
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
|
||||
#endif
|
||||
void System.Collections.ICollection.CopyTo(Array array, int arrayIndex) {
|
||||
if ((array != null) && (array.Rank != 1)) {
|
||||
ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_RankMultiDimNotSupported);
|
||||
@@ -447,7 +420,6 @@ namespace System.Collections.Generic {
|
||||
}
|
||||
}
|
||||
|
||||
#if FEATURE_LIST_PREDICATES || FEATURE_NETCORE
|
||||
public bool Exists(Predicate<T> match) {
|
||||
return FindIndex(match) != -1;
|
||||
}
|
||||
@@ -576,7 +548,6 @@ namespace System.Collections.Generic {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#endif // FEATURE_LIST_PREDICATES || FEATURE_NETCORE
|
||||
|
||||
public void ForEach(Action<T> action) {
|
||||
if( action == null) {
|
||||
@@ -602,24 +573,15 @@ namespace System.Collections.Generic {
|
||||
// while an enumeration is in progress, the MoveNext and
|
||||
// GetObject methods of the enumerator will throw an exception.
|
||||
//
|
||||
#if !FEATURE_CORECLR
|
||||
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
|
||||
#endif
|
||||
public Enumerator GetEnumerator() {
|
||||
return new Enumerator(this);
|
||||
}
|
||||
|
||||
/// <internalonly/>
|
||||
#if !FEATURE_CORECLR
|
||||
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
|
||||
#endif
|
||||
IEnumerator<T> IEnumerable<T>.GetEnumerator() {
|
||||
return new Enumerator(this);
|
||||
}
|
||||
|
||||
#if !FEATURE_CORECLR
|
||||
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
|
||||
#endif
|
||||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
|
||||
return new Enumerator(this);
|
||||
}
|
||||
@@ -654,18 +616,12 @@ namespace System.Collections.Generic {
|
||||
// This method uses the Array.IndexOf method to perform the
|
||||
// search.
|
||||
//
|
||||
#if !FEATURE_CORECLR
|
||||
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
|
||||
#endif
|
||||
public int IndexOf(T item) {
|
||||
Contract.Ensures(Contract.Result<int>() >= -1);
|
||||
Contract.Ensures(Contract.Result<int>() < Count);
|
||||
return Array.IndexOf(_items, item, 0, _size);
|
||||
}
|
||||
|
||||
#if !FEATURE_CORECLR
|
||||
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
|
||||
#endif
|
||||
int System.Collections.IList.IndexOf(Object item)
|
||||
{
|
||||
if(IsCompatibleObject(item)) {
|
||||
@@ -871,9 +827,6 @@ namespace System.Collections.Generic {
|
||||
// Removes the element at the given index. The size of the list is
|
||||
// decreased by one.
|
||||
//
|
||||
#if !FEATURE_CORECLR
|
||||
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
|
||||
#endif
|
||||
public bool Remove(T item) {
|
||||
int index = IndexOf(item);
|
||||
if (index >= 0) {
|
||||
@@ -1074,7 +1027,6 @@ namespace System.Collections.Generic {
|
||||
}
|
||||
}
|
||||
|
||||
#if FEATURE_LIST_PREDICATES || FEATURE_NETCORE
|
||||
public bool TrueForAll(Predicate<T> match) {
|
||||
if( match == null) {
|
||||
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match);
|
||||
@@ -1088,7 +1040,6 @@ namespace System.Collections.Generic {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif // FEATURE_LIST_PREDICATES || FEATURE_NETCORE
|
||||
|
||||
internal static IList<T> Synchronized(List<T> list) {
|
||||
return new SynchronizedList(list);
|
||||
@@ -1207,9 +1158,6 @@ namespace System.Collections.Generic {
|
||||
current = default(T);
|
||||
}
|
||||
|
||||
#if !FEATURE_CORECLR
|
||||
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
|
||||
#endif
|
||||
public void Dispose() {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user