From a7ddca7fd1760a1b666c0b8f949415436a5a3392 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Fri, 10 Jan 2020 18:56:06 -0800 Subject: [PATCH] Partial Revert "Add asserts to catch unintentional use of generic overloads (#1200)" This reverts commit f6d14eeaf290a78e547f4cf15476e61b53e06b5c. --- .../src/System/SpanHelpers.T.cs | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs index 87918217de1db6..fce93c4f1ef008 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs @@ -13,9 +13,6 @@ internal static partial class SpanHelpers // .T { public static int IndexOf(ref T searchSpace, int searchSpaceLength, ref T value, int valueLength) where T : IEquatable { - // The optimized implementation should be used for these types - Debug.Assert(!RuntimeHelpers.IsBitwiseEquatable() || !(Unsafe.SizeOf() == sizeof(byte) || Unsafe.SizeOf() == sizeof(char))); - Debug.Assert(searchSpaceLength >= 0); Debug.Assert(valueLength >= 0); @@ -52,9 +49,6 @@ public static int IndexOf(ref T searchSpace, int searchSpaceLength, ref T val // Adapted from IndexOf(...) public static unsafe bool Contains(ref T searchSpace, T value, int length) where T : IEquatable { - // The optimized implementation should be used for these types - Debug.Assert(!RuntimeHelpers.IsBitwiseEquatable() || !(Unsafe.SizeOf() == sizeof(byte) || Unsafe.SizeOf() == sizeof(char))); - Debug.Assert(length >= 0); IntPtr index = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations @@ -125,9 +119,6 @@ public static unsafe bool Contains(ref T searchSpace, T value, int length) wh public static unsafe int IndexOf(ref T searchSpace, T value, int length) where T : IEquatable { - // The optimized implementation should be used for these types - Debug.Assert(!RuntimeHelpers.IsBitwiseEquatable() || !(Unsafe.SizeOf() == sizeof(byte) || Unsafe.SizeOf() == sizeof(char))); - Debug.Assert(length >= 0); IntPtr index = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations @@ -215,9 +206,6 @@ public static unsafe int IndexOf(ref T searchSpace, T value, int length) wher public static int IndexOfAny(ref T searchSpace, T value0, T value1, int length) where T : IEquatable { - // The optimized implementation should be used for these types - Debug.Assert(!RuntimeHelpers.IsBitwiseEquatable() || !(Unsafe.SizeOf() == sizeof(byte) || Unsafe.SizeOf() == sizeof(char))); - Debug.Assert(length >= 0); T lookUp; @@ -322,9 +310,6 @@ public static int IndexOfAny(ref T searchSpace, T value0, T value1, int lengt public static int IndexOfAny(ref T searchSpace, T value0, T value1, T value2, int length) where T : IEquatable { - // The optimized implementation should be used for these types - Debug.Assert(!RuntimeHelpers.IsBitwiseEquatable() || !(Unsafe.SizeOf() == sizeof(byte) || Unsafe.SizeOf() == sizeof(char))); - Debug.Assert(length >= 0); T lookUp; @@ -428,9 +413,6 @@ public static int IndexOfAny(ref T searchSpace, T value0, T value1, T value2, public static int IndexOfAny(ref T searchSpace, int searchSpaceLength, ref T value, int valueLength) where T : IEquatable { - // The optimized implementation should be used for these types - Debug.Assert(!RuntimeHelpers.IsBitwiseEquatable() || !(Unsafe.SizeOf() == sizeof(byte) || Unsafe.SizeOf() == sizeof(char))); - Debug.Assert(searchSpaceLength >= 0); Debug.Assert(valueLength >= 0); @@ -490,9 +472,6 @@ public static int LastIndexOf(ref T searchSpace, int searchSpaceLength, ref T public static int LastIndexOf(ref T searchSpace, T value, int length) where T : IEquatable { - // The optimized implementation should be used for these types - Debug.Assert(!RuntimeHelpers.IsBitwiseEquatable() || !(Unsafe.SizeOf() == sizeof(byte) || Unsafe.SizeOf() == sizeof(char))); - Debug.Assert(length >= 0); if (default(T)! != null || (object)value != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) @@ -574,9 +553,6 @@ public static int LastIndexOf(ref T searchSpace, T value, int length) where T public static int LastIndexOfAny(ref T searchSpace, T value0, T value1, int length) where T : IEquatable { - // The optimized implementation should be used for these types - Debug.Assert(!RuntimeHelpers.IsBitwiseEquatable() || !(Unsafe.SizeOf() == sizeof(byte) || Unsafe.SizeOf() == sizeof(char))); - Debug.Assert(length >= 0); T lookUp; @@ -680,9 +656,6 @@ public static int LastIndexOfAny(ref T searchSpace, T value0, T value1, int l public static int LastIndexOfAny(ref T searchSpace, T value0, T value1, T value2, int length) where T : IEquatable { - // The optimized implementation should be used for these types - Debug.Assert(!RuntimeHelpers.IsBitwiseEquatable() || !(Unsafe.SizeOf() == sizeof(byte) || Unsafe.SizeOf() == sizeof(char))); - Debug.Assert(length >= 0); T lookUp; @@ -786,9 +759,6 @@ public static int LastIndexOfAny(ref T searchSpace, T value0, T value1, T val public static int LastIndexOfAny(ref T searchSpace, int searchSpaceLength, ref T value, int valueLength) where T : IEquatable { - // The optimized implementation should be used for these types - Debug.Assert(!RuntimeHelpers.IsBitwiseEquatable() || !(Unsafe.SizeOf() == sizeof(byte) || Unsafe.SizeOf() == sizeof(char))); - Debug.Assert(searchSpaceLength >= 0); Debug.Assert(valueLength >= 0); @@ -807,9 +777,6 @@ public static int LastIndexOfAny(ref T searchSpace, int searchSpaceLength, re public static bool SequenceEqual(ref T first, ref T second, int length) where T : IEquatable { - // The optimized implementation should be used for these types - Debug.Assert(!RuntimeHelpers.IsBitwiseEquatable() || !(Unsafe.SizeOf() == sizeof(byte) || Unsafe.SizeOf() == sizeof(char))); - Debug.Assert(length >= 0); if (Unsafe.AreSame(ref first, ref second)) @@ -902,9 +869,6 @@ public static bool SequenceEqual(ref T first, ref T second, int length) where public static int SequenceCompareTo(ref T first, int firstLength, ref T second, int secondLength) where T : IComparable { - // The optimized implementation should be used for these types - Debug.Assert(typeof(T) != typeof(byte) && typeof(T) != typeof(char)); - Debug.Assert(firstLength >= 0); Debug.Assert(secondLength >= 0);