Delete Span ifdefs that are no longer needed (#18982)
authorJan Kotas <jkotas@microsoft.com>
Wed, 18 Jul 2018 10:13:15 +0000 (03:13 -0700)
committerGitHub <noreply@github.com>
Wed, 18 Jul 2018 10:13:15 +0000 (03:13 -0700)
src/System.Private.CoreLib/shared/System/Memory.cs
src/System.Private.CoreLib/shared/System/MemoryExtensions.cs
src/System.Private.CoreLib/shared/System/ReadOnlyMemory.cs
src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs
src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MemoryMarshal.cs
src/System.Private.CoreLib/shared/System/Span.cs
src/System.Private.CoreLib/shared/System/SpanHelpers.BinarySearch.cs
src/System.Private.CoreLib/shared/System/SpanHelpers.Byte.cs

index 0abe3634ae7139c78a825483528ff48bbf587e17..1a7556720d6289b9787a4d2896fdde6ec525447c 100644 (file)
@@ -8,9 +8,8 @@ using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using EditorBrowsableAttribute = System.ComponentModel.EditorBrowsableAttribute;
 using EditorBrowsableState = System.ComponentModel.EditorBrowsableState;
-#if !FEATURE_PORTABLE_SPAN
+
 using Internal.Runtime.CompilerServices;
-#endif // FEATURE_PORTABLE_SPAN
 
 namespace System
 {
@@ -282,11 +281,7 @@ namespace System
                     // and then cast to a Memory<T>. Such a cast can only be done with unsafe or marshaling code,
                     // in which case that's the dangerous operation performed by the dev, and we're just following
                     // suit here to make it work as best as possible.
-#if FEATURE_PORTABLE_SPAN
-                    return new Span<T>(Unsafe.As<Pinnable<T>>(s), MemoryExtensions.StringAdjustment, s.Length).Slice(_index, _length);
-#else
                     return new Span<T>(ref Unsafe.As<char, T>(ref s.GetRawStringData()), s.Length).Slice(_index, _length);
-#endif // FEATURE_PORTABLE_SPAN
                 }
                 else if (_object != null)
                 {
@@ -345,11 +340,7 @@ namespace System
                 // a readable ReadOnlyMemory<char> or a writable Memory<char> can still be pinned and
                 // used for interop purposes.
                 GCHandle handle = GCHandle.Alloc(s, GCHandleType.Pinned);
-#if FEATURE_PORTABLE_SPAN
-                void* pointer = Unsafe.Add<T>((void*)handle.AddrOfPinnedObject(), _index);
-#else
                 void* pointer = Unsafe.Add<T>(Unsafe.AsPointer(ref s.GetRawStringData()), _index);
-#endif // FEATURE_PORTABLE_SPAN
                 return new MemoryHandle(pointer, handle);
             }
             else if (_object is T[] array)
@@ -357,21 +348,13 @@ namespace System
                 // Array is already pre-pinned
                 if (_length < 0)
                 {
-#if FEATURE_PORTABLE_SPAN
-                    void* pointer = Unsafe.Add<T>(Unsafe.AsPointer(ref MemoryMarshal.GetReference<T>(array)), _index);
-#else
                     void* pointer = Unsafe.Add<T>(Unsafe.AsPointer(ref array.GetRawSzArrayData()), _index);
-#endif // FEATURE_PORTABLE_SPAN
                     return new MemoryHandle(pointer);
                 }
                 else
                 {
                     GCHandle handle = GCHandle.Alloc(array, GCHandleType.Pinned);
-#if FEATURE_PORTABLE_SPAN
-                    void* pointer = Unsafe.Add<T>((void*)handle.AddrOfPinnedObject(), _index);
-#else
                     void* pointer = Unsafe.Add<T>(Unsafe.AsPointer(ref array.GetRawSzArrayData()), _index);
-#endif // FEATURE_PORTABLE_SPAN
                     return new MemoryHandle(pointer, handle);
                 }
             }
index 639bf06e106a8f2ef592213eb358fbb352a13f2c..739bc3145d1cc164ae75153adc2fd5fa175e4a8b 100644 (file)
@@ -6,19 +6,13 @@ using System.Collections.Generic;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
-#if !netstandard
 using Internal.Runtime.CompilerServices;
-#endif
 
-#if netstandard
-using nuint = System.NUInt;
-#else
 #if BIT64
 using nuint = System.UInt64;
 #else
 using nuint = System.UInt32;
 #endif // BIT64
-#endif // netstandard
 
 namespace System
 {
@@ -1360,26 +1354,25 @@ namespace System
         {
             if (typeof(T) == typeof(byte) || typeof(T) == typeof(sbyte))
             {
-                // The cast to nuint is not redundant on netstandard. Do not remove it.
-                size = (nuint)sizeof(byte);
+                size = sizeof(byte);
                 return true;
             }
 
             if (typeof(T) == typeof(char) || typeof(T) == typeof(short) || typeof(T) == typeof(ushort))
             {
-                size = (nuint)sizeof(char);
+                size = sizeof(char);
                 return true;
             }
 
             if (typeof(T) == typeof(int) || typeof(T) == typeof(uint))
             {
-                size = (nuint)sizeof(int);
+                size = sizeof(int);
                 return true;
             }
 
             if (typeof(T) == typeof(long) || typeof(T) == typeof(ulong))
             {
-                size = (nuint)sizeof(long);
+                size = sizeof(long);
                 return true;
             }
 
index 78f328a8803389039c114efe80e84607fbe643bc..02445ec5c640335940934070938db8c28f051c70 100644 (file)
@@ -8,9 +8,8 @@ using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using EditorBrowsableAttribute = System.ComponentModel.EditorBrowsableAttribute;
 using EditorBrowsableState = System.ComponentModel.EditorBrowsableState;
-#if !FEATURE_PORTABLE_SPAN
+
 using Internal.Runtime.CompilerServices;
-#endif // FEATURE_PORTABLE_SPAN
 
 namespace System
 {
@@ -199,11 +198,7 @@ namespace System
                 else if (typeof(T) == typeof(char) && _object is string s)
                 {
                     Debug.Assert(_length >= 0);
-#if FEATURE_PORTABLE_SPAN
-                    return new ReadOnlySpan<T>(Unsafe.As<Pinnable<T>>(s), MemoryExtensions.StringAdjustment, s.Length).Slice(_index, _length);
-#else
                     return new ReadOnlySpan<T>(ref Unsafe.As<char, T>(ref s.GetRawStringData()), s.Length).Slice(_index, _length);
-#endif // FEATURE_PORTABLE_SPAN
                 }
                 else if (_object != null)
                 {
@@ -257,11 +252,7 @@ namespace System
             else if (typeof(T) == typeof(char) && _object is string s)
             {
                 GCHandle handle = GCHandle.Alloc(s, GCHandleType.Pinned);
-#if FEATURE_PORTABLE_SPAN
-                void* pointer = Unsafe.Add<T>((void*)handle.AddrOfPinnedObject(), _index);
-#else
                 void* pointer = Unsafe.Add<T>(Unsafe.AsPointer(ref s.GetRawStringData()), _index);
-#endif // FEATURE_PORTABLE_SPAN
                 return new MemoryHandle(pointer, handle);
             }
             else if (_object is T[] array)
@@ -269,21 +260,13 @@ namespace System
                 // Array is already pre-pinned
                 if (_length < 0)
                 {
-#if FEATURE_PORTABLE_SPAN
-                    void* pointer = Unsafe.Add<T>(Unsafe.AsPointer(ref MemoryMarshal.GetReference<T>(array)), _index);
-#else
                     void* pointer = Unsafe.Add<T>(Unsafe.AsPointer(ref array.GetRawSzArrayData()), _index);
-#endif // FEATURE_PORTABLE_SPAN
                     return new MemoryHandle(pointer);
                 }
                 else
                 {
                     GCHandle handle = GCHandle.Alloc(array, GCHandleType.Pinned);
-#if FEATURE_PORTABLE_SPAN
-                    void* pointer = Unsafe.Add<T>((void*)handle.AddrOfPinnedObject(), _index);
-#else
                     void* pointer = Unsafe.Add<T>(Unsafe.AsPointer(ref array.GetRawSzArrayData()), _index);
-#endif // FEATURE_PORTABLE_SPAN
                     return new MemoryHandle(pointer, handle);
                 }
             }
index 52a160ddeda1ed077b01a2792514384876be75f0..61af717836a56ed217eb1b4b4e3950c31ac421ce 100644 (file)
@@ -5,9 +5,8 @@
 using System.ComponentModel;
 using System.Diagnostics;
 using System.Runtime.CompilerServices;
-#if !FEATURE_PORTABLE_SPAN
+
 using System.Runtime.Versioning;
-#endif // !FEATURE_PORTABLE_SPAN
 
 #pragma warning disable 0809  //warning CS0809: Obsolete member 'Span<T>.Equals(object)' overrides non-obsolete member 'object.Equals(object)'
 
@@ -26,9 +25,7 @@ namespace System
         /// </summary>
         public int Length
         {
-#if !FEATURE_PORTABLE_SPAN
             [NonVersionable]
-#endif // !FEATURE_PORTABLE_SPAN
             get
             {
                 return _length;
@@ -40,9 +37,7 @@ namespace System
         /// </summary>
         public bool IsEmpty
         {
-#if !FEATURE_PORTABLE_SPAN
             [NonVersionable]
-#endif // !FEATURE_PORTABLE_SPAN
             get
             {
                 return _length == 0;
index 77f497512b7c95be7d12bda226b88c7df7c00d49..5e33ced6b8753e5ae08a37ceb0dcc2669e3e3d42 100644 (file)
@@ -7,9 +7,7 @@ using System.Runtime.CompilerServices;
 using System.Collections.Generic;
 using System.Diagnostics;
 
-#if !netstandard
 using Internal.Runtime.CompilerServices;
-#endif
 
 namespace System.Runtime.InteropServices
 {
@@ -43,11 +41,7 @@ namespace System.Runtime.InteropServices
 
             if ((length & ReadOnlyMemory<T>.RemoveFlagsBitMask) == 0)
             {
-#if FEATURE_PORTABLE_SPAN
-                segment = new ArraySegment<T>(SpanHelpers.PerTypeValues<T>.EmptyArray);
-#else
                 segment = ArraySegment<T>.Empty;
-#endif // FEATURE_PORTABLE_SPAN
                 return true;
             }
 
@@ -147,17 +141,10 @@ namespace System.Runtime.InteropServices
         public static T Read<T>(ReadOnlySpan<byte> source)
             where T : struct
         {
-#if netstandard
-            if (SpanHelpers.IsReferenceOrContainsReferences<T>())
-            {
-                ThrowHelper.ThrowArgumentException_InvalidTypeWithPointersNotSupported(typeof(T));
-            }
-#else
             if (RuntimeHelpers.IsReferenceOrContainsReferences<T>())
             {
                 ThrowHelper.ThrowInvalidTypeWithPointersNotSupported(typeof(T));
             }
-#endif
             if (Unsafe.SizeOf<T>() > source.Length)
             {
                 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length);
@@ -173,17 +160,10 @@ namespace System.Runtime.InteropServices
         public static bool TryRead<T>(ReadOnlySpan<byte> source, out T value)
             where T : struct
         {
-#if netstandard
-            if (SpanHelpers.IsReferenceOrContainsReferences<T>())
-            {
-                ThrowHelper.ThrowArgumentException_InvalidTypeWithPointersNotSupported(typeof(T));
-            }
-#else
             if (RuntimeHelpers.IsReferenceOrContainsReferences<T>())
             {
                 ThrowHelper.ThrowInvalidTypeWithPointersNotSupported(typeof(T));
             }
-#endif
             if (Unsafe.SizeOf<T>() > (uint)source.Length)
             {
                 value = default;
@@ -200,17 +180,10 @@ namespace System.Runtime.InteropServices
         public static void Write<T>(Span<byte> destination, ref T value)
             where T : struct
         {
-#if netstandard
-            if (SpanHelpers.IsReferenceOrContainsReferences<T>())
-            {
-                ThrowHelper.ThrowArgumentException_InvalidTypeWithPointersNotSupported(typeof(T));
-            }
-#else
             if (RuntimeHelpers.IsReferenceOrContainsReferences<T>())
             {
                 ThrowHelper.ThrowInvalidTypeWithPointersNotSupported(typeof(T));
             }
-#endif
             if ((uint)Unsafe.SizeOf<T>() > (uint)destination.Length)
             {
                 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length);
@@ -226,17 +199,10 @@ namespace System.Runtime.InteropServices
         public static bool TryWrite<T>(Span<byte> destination, ref T value)
             where T : struct
         {
-#if netstandard
-            if (SpanHelpers.IsReferenceOrContainsReferences<T>())
-            {
-                ThrowHelper.ThrowArgumentException_InvalidTypeWithPointersNotSupported(typeof(T));
-            }
-#else
             if (RuntimeHelpers.IsReferenceOrContainsReferences<T>())
             {
                 ThrowHelper.ThrowInvalidTypeWithPointersNotSupported(typeof(T));
             }
-#endif
             if (Unsafe.SizeOf<T>() > (uint)destination.Length)
             {
                 return false;
index 2bafa1daf8298c9e93bb057cd0cccf6b4e3f2b3e..ddbdba1134bc40eeed09217fd66ccd7a9dfc12bf 100644 (file)
@@ -5,9 +5,8 @@
 using System.ComponentModel;
 using System.Diagnostics;
 using System.Runtime.CompilerServices;
-#if !FEATURE_PORTABLE_SPAN
+
 using System.Runtime.Versioning;
-#endif // !FEATURE_PORTABLE_SPAN
 
 #pragma warning disable 0809  //warning CS0809: Obsolete member 'Span<T>.Equals(object)' overrides non-obsolete member 'object.Equals(object)'
 
@@ -26,9 +25,7 @@ namespace System
         /// </summary>
         public int Length
         {
-#if !FEATURE_PORTABLE_SPAN
             [NonVersionable]
-#endif // !FEATURE_PORTABLE_SPAN
             get
             {
                 return _length;
@@ -40,9 +37,7 @@ namespace System
         /// </summary>
         public bool IsEmpty
         {
-#if !FEATURE_PORTABLE_SPAN
             [NonVersionable]
-#endif // !FEATURE_PORTABLE_SPAN
             get
             {
                 return _length == 0;
index 00c491f37f4b072b9f0bae3f2faa766cb5fa84d3..a81a5d3416f093b588fd4d3fe15270784db15912 100644 (file)
@@ -6,9 +6,7 @@ using System.Collections.Generic;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
-#if !netstandard
 using Internal.Runtime.CompilerServices;
-#endif
 
 namespace System
 {
index 0c7309b5c526968a21b5b39462c8160c3652f86c..2890adb568f402a117b4ab50182aac5a2968007d 100644 (file)
@@ -4,24 +4,15 @@
 
 using System.Diagnostics;
 using System.Runtime.CompilerServices;
+using System.Numerics;
 
-#if !netstandard
 using Internal.Runtime.CompilerServices;
-#endif
-
-#if !netstandard11
-using System.Numerics;
-#endif
 
-#if netstandard
-using nuint = System.NUInt;
-#else
 #if BIT64
 using nuint = System.UInt64;
 #else
 using nuint = System.UInt32;
 #endif // BIT64
-#endif // netstandard
 
 namespace System
 {
@@ -112,14 +103,13 @@ namespace System
             uint uValue = value; // Use uint for comparisons to avoid unnecessary 8->32 extensions
             IntPtr index = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations
             IntPtr nLength = (IntPtr)length;
-#if !netstandard11
+
             if (Vector.IsHardwareAccelerated && length >= Vector<byte>.Count * 2)
             {
                 int unaligned = (int)Unsafe.AsPointer(ref searchSpace) & (Vector<byte>.Count - 1);
                 nLength = (IntPtr)((Vector<byte>.Count - unaligned) & (Vector<byte>.Count - 1));
             }
         SequentialScan:
-#endif
             while ((byte*)nLength >= (byte*)8)
             {
                 nLength -= 8;
@@ -169,13 +159,13 @@ namespace System
 
                 index += 1;
             }
-#if !netstandard11
+
             if (Vector.IsHardwareAccelerated && ((int)(byte*)index < length))
             {
                 nLength = (IntPtr)((length - (int)(byte*)index) & ~(Vector<byte>.Count - 1));
 
                 // Get comparison Vector
-                Vector<byte> vComparison = GetVector(value);
+                Vector<byte> vComparison = new Vector<byte>(value);
 
                 while ((byte*)nLength > (byte*)index)
                 {
@@ -195,7 +185,6 @@ namespace System
                     goto SequentialScan;
                 }
             }
-#endif
             return -1;
         Found: // Workaround for https://github.com/dotnet/coreclr/issues/13549
             return (int)(byte*)index;
@@ -256,14 +245,13 @@ namespace System
             uint uValue = value; // Use uint for comparisons to avoid unnecessary 8->32 extensions
             IntPtr index = (IntPtr)length; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations
             IntPtr nLength = (IntPtr)length;
-#if !netstandard11
+
             if (Vector.IsHardwareAccelerated && length >= Vector<byte>.Count * 2)
             {
                 int unaligned = (int)Unsafe.AsPointer(ref searchSpace) & (Vector<byte>.Count - 1);
                 nLength = (IntPtr)(((length & (Vector<byte>.Count - 1)) + unaligned) & (Vector<byte>.Count - 1));
             }
         SequentialScan:
-#endif
             while ((byte*)nLength >= (byte*)8)
             {
                 nLength -= 8;
@@ -310,13 +298,13 @@ namespace System
                 if (uValue == Unsafe.AddByteOffset(ref searchSpace, index))
                     goto Found;
             }
-#if !netstandard11
+
             if (Vector.IsHardwareAccelerated && ((byte*)index > (byte*)0))
             {
                 nLength = (IntPtr)((int)(byte*)index & ~(Vector<byte>.Count - 1));
 
                 // Get comparison Vector
-                Vector<byte> vComparison = GetVector(value);
+                Vector<byte> vComparison = new Vector<byte>(value);
 
                 while ((byte*)nLength > (byte*)(Vector<byte>.Count - 1))
                 {
@@ -336,7 +324,6 @@ namespace System
                     goto SequentialScan;
                 }
             }
-#endif
             return -1;
         Found: // Workaround for https://github.com/dotnet/coreclr/issues/13549
             return (int)(byte*)index;
@@ -364,14 +351,13 @@ namespace System
             uint uValue1 = value1; // Use uint for comparisons to avoid unnecessary 8->32 extensions
             IntPtr index = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations
             IntPtr nLength = (IntPtr)length;
-#if !netstandard11
+
             if (Vector.IsHardwareAccelerated && length >= Vector<byte>.Count * 2)
             {
                 int unaligned = (int)Unsafe.AsPointer(ref searchSpace) & (Vector<byte>.Count - 1);
                 nLength = (IntPtr)((Vector<byte>.Count - unaligned) & (Vector<byte>.Count - 1));
             }
         SequentialScan:
-#endif
             uint lookUp;
             while ((byte*)nLength >= (byte*)8)
             {
@@ -435,14 +421,14 @@ namespace System
 
                 index += 1;
             }
-#if !netstandard11
+
             if (Vector.IsHardwareAccelerated && ((int)(byte*)index < length))
             {
                 nLength = (IntPtr)((length - (int)(byte*)index) & ~(Vector<byte>.Count - 1));
 
                 // Get comparison Vector
-                Vector<byte> values0 = GetVector(value0);
-                Vector<byte> values1 = GetVector(value1);
+                Vector<byte> values0 = new Vector<byte>(value0);
+                Vector<byte> values1 = new Vector<byte>(value1);
 
                 while ((byte*)nLength > (byte*)index)
                 {
@@ -465,7 +451,6 @@ namespace System
                     goto SequentialScan;
                 }
             }
-#endif
             return -1;
         Found: // Workaround for https://github.com/dotnet/coreclr/issues/13549
             return (int)(byte*)index;
@@ -494,14 +479,13 @@ namespace System
             uint uValue2 = value2; // Use uint for comparisons to avoid unnecessary 8->32 extensions
             IntPtr index = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations
             IntPtr nLength = (IntPtr)length;
-#if !netstandard11
+
             if (Vector.IsHardwareAccelerated && length >= Vector<byte>.Count * 2)
             {
                 int unaligned = (int)Unsafe.AsPointer(ref searchSpace) & (Vector<byte>.Count - 1);
                 nLength = (IntPtr)((Vector<byte>.Count - unaligned) & (Vector<byte>.Count - 1));
             }
         SequentialScan:
-#endif
             uint lookUp;
             while ((byte*)nLength >= (byte*)8)
             {
@@ -565,15 +549,15 @@ namespace System
 
                 index += 1;
             }
-#if !netstandard11
+
             if (Vector.IsHardwareAccelerated && ((int)(byte*)index < length))
             {
                 nLength = (IntPtr)((length - (int)(byte*)index) & ~(Vector<byte>.Count - 1));
 
                 // Get comparison Vector
-                Vector<byte> values0 = GetVector(value0);
-                Vector<byte> values1 = GetVector(value1);
-                Vector<byte> values2 = GetVector(value2);
+                Vector<byte> values0 = new Vector<byte>(value0);
+                Vector<byte> values1 = new Vector<byte>(value1);
+                Vector<byte> values2 = new Vector<byte>(value2);
 
                 while ((byte*)nLength > (byte*)index)
                 {
@@ -600,7 +584,6 @@ namespace System
                     goto SequentialScan;
                 }
             }
-#endif
             return -1;
         Found: // Workaround for https://github.com/dotnet/coreclr/issues/13549
             return (int)(byte*)index;
@@ -628,14 +611,13 @@ namespace System
             uint uValue1 = value1; // Use uint for comparisons to avoid unnecessary 8->32 extensions
             IntPtr index = (IntPtr)length; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations
             IntPtr nLength = (IntPtr)length;
-#if !netstandard11
+
             if (Vector.IsHardwareAccelerated && length >= Vector<byte>.Count * 2)
             {
                 int unaligned = (int)Unsafe.AsPointer(ref searchSpace) & (Vector<byte>.Count - 1);
                 nLength = (IntPtr)(((length & (Vector<byte>.Count - 1)) + unaligned) & (Vector<byte>.Count - 1));
             }
         SequentialScan:
-#endif
             uint lookUp;
             while ((byte*)nLength >= (byte*)8)
             {
@@ -696,14 +678,14 @@ namespace System
                 if (uValue0 == lookUp || uValue1 == lookUp)
                     goto Found;
             }
-#if !netstandard11
+
             if (Vector.IsHardwareAccelerated && ((byte*)index > (byte*)0))
             {
                 nLength = (IntPtr)((int)(byte*)index & ~(Vector<byte>.Count - 1));
 
                 // Get comparison Vector
-                Vector<byte> values0 = GetVector(value0);
-                Vector<byte> values1 = GetVector(value1);
+                Vector<byte> values0 = new Vector<byte>(value0);
+                Vector<byte> values1 = new Vector<byte>(value1);
 
                 while ((byte*)nLength > (byte*)(Vector<byte>.Count - 1))
                 {
@@ -727,7 +709,6 @@ namespace System
                     goto SequentialScan;
                 }
             }
-#endif
             return -1;
         Found: // Workaround for https://github.com/dotnet/coreclr/issues/13549
             return (int)(byte*)index;
@@ -756,14 +737,13 @@ namespace System
             uint uValue2 = value2; // Use uint for comparisons to avoid unnecessary 8->32 extensions
             IntPtr index = (IntPtr)length; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations
             IntPtr nLength = (IntPtr)length;
-#if !netstandard11
+
             if (Vector.IsHardwareAccelerated && length >= Vector<byte>.Count * 2)
             {
                 int unaligned = (int)Unsafe.AsPointer(ref searchSpace) & (Vector<byte>.Count - 1);
                 nLength = (IntPtr)(((length & (Vector<byte>.Count - 1)) + unaligned) & (Vector<byte>.Count - 1));
             }
         SequentialScan:
-#endif
             uint lookUp;
             while ((byte*)nLength >= (byte*)8)
             {
@@ -824,15 +804,15 @@ namespace System
                 if (uValue0 == lookUp || uValue1 == lookUp || uValue2 == lookUp)
                     goto Found;
             }
-#if !netstandard11
+
             if (Vector.IsHardwareAccelerated && ((byte*)index > (byte*)0))
             {
                 nLength = (IntPtr)((int)(byte*)index & ~(Vector<byte>.Count - 1));
 
                 // Get comparison Vector
-                Vector<byte> values0 = GetVector(value0);
-                Vector<byte> values1 = GetVector(value1);
-                Vector<byte> values2 = GetVector(value2);
+                Vector<byte> values0 = new Vector<byte>(value0);
+                Vector<byte> values1 = new Vector<byte>(value1);
+                Vector<byte> values2 = new Vector<byte>(value2);
 
                 while ((byte*)nLength > (byte*)(Vector<byte>.Count - 1))
                 {
@@ -860,7 +840,6 @@ namespace System
                     goto SequentialScan;
                 }
             }
-#endif
             return -1;
         Found: // Workaround for https://github.com/dotnet/coreclr/issues/13549
             return (int)(byte*)index;
@@ -890,7 +869,6 @@ namespace System
             IntPtr i = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations
             IntPtr n = (IntPtr)(void*)length;
 
-#if !netstandard11
             if (Vector.IsHardwareAccelerated && (byte*)n >= (byte*)Vector<byte>.Count)
             {
                 n -= Vector<byte>.Count;
@@ -906,7 +884,6 @@ namespace System
                 return Unsafe.ReadUnaligned<Vector<byte>>(ref Unsafe.AddByteOffset(ref first, n)) ==
                        Unsafe.ReadUnaligned<Vector<byte>>(ref Unsafe.AddByteOffset(ref second, n));
             }
-#endif
 
             if ((byte*)n >= (byte*)sizeof(UIntPtr))
             {
@@ -938,7 +915,6 @@ namespace System
             return false;
         }
 
-#if !netstandard11
         // Vector sub-search adapted from https://github.com/aspnet/KestrelHttpServer/pull/1138
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
         private static int LocateFirstFoundByte(Vector<byte> match)
@@ -959,7 +935,6 @@ namespace System
             // Single LEA instruction with jitted const (using function result)
             return i * 8 + LocateFirstFoundByte(candidate);
         }
-#endif
 
         public static unsafe int SequenceCompareTo(ref byte first, int firstLength, ref byte second, int secondLength)
         {
@@ -974,7 +949,6 @@ namespace System
             IntPtr i = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations
             IntPtr n = (IntPtr)(void*)minLength;
 
-#if !netstandard11
             if (Vector.IsHardwareAccelerated && (byte*)n > (byte*)Vector<byte>.Count)
             {
                 n -= Vector<byte>.Count;
@@ -989,7 +963,6 @@ namespace System
                 }
                 goto NotEqual;
             }
-#endif
 
             if ((byte*)n > (byte*)sizeof(UIntPtr))
             {
@@ -1018,7 +991,6 @@ namespace System
             return firstLength - secondLength;
         }
 
-#if !netstandard11
         // Vector sub-search adapted from https://github.com/aspnet/KestrelHttpServer/pull/1138
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
         private static int LocateLastFoundByte(Vector<byte> match)
@@ -1039,9 +1011,7 @@ namespace System
             // Single LEA instruction with jitted const (using function result)
             return i * 8 + LocateLastFoundByte(candidate);
         }
-#endif
 
-#if !netstandard11
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
         private static int LocateFirstFoundByte(ulong match)
         {
@@ -1050,9 +1020,7 @@ namespace System
             // Shift all powers of two into the high byte and extract
             return (int)((powerOfTwoFlag * XorPowerOfTwoToHighByte) >> 57);
         }
-#endif
 
-#if !netstandard11
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
         private static int LocateLastFoundByte(ulong match)
         {
@@ -1065,24 +1033,7 @@ namespace System
             }
             return index;
         }
-#endif
-
-#if !netstandard11
-        [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        private static Vector<byte> GetVector(byte vectorByte)
-        {
-#if !netcoreapp
-            // Vector<byte> .ctor doesn't become an intrinsic due to detection issue
-            // However this does cause it to become an intrinsic (with additional multiply and reg->reg copy)
-            // https://github.com/dotnet/coreclr/issues/7459#issuecomment-253965670
-            return Vector.AsVectorByte(new Vector<uint>(vectorByte * 0x01010101u));
-#else
-            return new Vector<byte>(vectorByte);
-#endif
-        }
-#endif
 
-#if !netstandard11
         private const ulong XorPowerOfTwoToHighByte = (0x07ul |
                                                        0x06ul << 8 |
                                                        0x05ul << 16 |
@@ -1090,6 +1041,5 @@ namespace System
                                                        0x03ul << 32 |
                                                        0x02ul << 40 |
                                                        0x01ul << 48) + 1;
-#endif
     }
 }