diff --git a/src/DotNext.Tests/Buffers/Text/HexTests.cs b/src/DotNext.Tests/Buffers/Text/HexTests.cs index b11710737..b07ec6d9b 100644 --- a/src/DotNext.Tests/Buffers/Text/HexTests.cs +++ b/src/DotNext.Tests/Buffers/Text/HexTests.cs @@ -28,7 +28,7 @@ public static void ToUtf16(int arraySize, bool lowercased) [Fact] public static void ToUtf16ConversionVarLength() { - ReadOnlySpan data = new byte[] { 1, 2 }; + ReadOnlySpan data = stackalloc byte[] { 1, 2 }; char[] encoded = new char[1]; Equal(0, Hex.EncodeToUtf16(data, encoded)); encoded = new char[2]; @@ -40,7 +40,7 @@ public static void ToUtf16ConversionVarLength() [Fact] public static void FromUtf16ConversionVarLength() { - ReadOnlySpan data = new char[] { 'F', 'F', 'A' }; + ReadOnlySpan data = stackalloc char[] { 'F', 'F', 'A' }; var decoded = new byte[1]; Equal(1, Hex.DecodeFromUtf16(data, decoded)); Equal(byte.MaxValue, decoded[0]); diff --git a/src/DotNext/Buffers/Text/Hex.Unicode.cs b/src/DotNext/Buffers/Text/Hex.Unicode.cs index 11994e2bc..86e0c5b90 100644 --- a/src/DotNext/Buffers/Text/Hex.Unicode.cs +++ b/src/DotNext/Buffers/Text/Hex.Unicode.cs @@ -158,7 +158,7 @@ static Vector256 Fetch(ref byte bytePtr) offset = 0; } - ref char hexTable = ref MemoryMarshal.GetArrayDataReference(NibbleToUtf16CharLookupTable); + ref char hexTable = ref MemoryMarshal.GetReference(NibbleToUtf16CharLookupTable); if (!lowercased) hexTable = ref Add(ref hexTable, 16); diff --git a/src/DotNext/Buffers/Text/Hex.Utf8.cs b/src/DotNext/Buffers/Text/Hex.Utf8.cs index 87de6e5f8..67d5eb0fe 100644 --- a/src/DotNext/Buffers/Text/Hex.Utf8.cs +++ b/src/DotNext/Buffers/Text/Hex.Utf8.cs @@ -104,7 +104,7 @@ static Vector256 Fetch(ref byte bytePtr) offset = 0; } - ref char hexTable = ref MemoryMarshal.GetArrayDataReference(NibbleToUtf16CharLookupTable); + ref char hexTable = ref MemoryMarshal.GetReference(NibbleToUtf16CharLookupTable); if (!lowercased) hexTable = ref Add(ref hexTable, 16); diff --git a/src/DotNext/Buffers/Text/Hex.cs b/src/DotNext/Buffers/Text/Hex.cs index 530104ff0..66ffcf800 100644 --- a/src/DotNext/Buffers/Text/Hex.cs +++ b/src/DotNext/Buffers/Text/Hex.cs @@ -13,7 +13,7 @@ public static partial class Hex { private const byte NibbleMaxValue = 0B1111; - private static readonly char[] NibbleToUtf16CharLookupTable = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']; + private static ReadOnlySpan NibbleToUtf16CharLookupTable => ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']; private static ReadOnlySpan CharToNibbleLookupTable => [