Skip to content

Commit

Permalink
Migration to static PE data field
Browse files Browse the repository at this point in the history
  • Loading branch information
sakno committed Jan 12, 2024
1 parent 3b11ea2 commit ecdafa3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/DotNext.Tests/Buffers/Text/HexTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static void ToUtf16(int arraySize, bool lowercased)
[Fact]
public static void ToUtf16ConversionVarLength()
{
ReadOnlySpan<byte> data = new byte[] { 1, 2 };
ReadOnlySpan<byte> data = stackalloc byte[] { 1, 2 };
char[] encoded = new char[1];
Equal(0, Hex.EncodeToUtf16(data, encoded));
encoded = new char[2];
Expand All @@ -40,7 +40,7 @@ public static void ToUtf16ConversionVarLength()
[Fact]
public static void FromUtf16ConversionVarLength()
{
ReadOnlySpan<char> data = new char[] { 'F', 'F', 'A' };
ReadOnlySpan<char> data = stackalloc char[] { 'F', 'F', 'A' };
var decoded = new byte[1];
Equal(1, Hex.DecodeFromUtf16(data, decoded));
Equal(byte.MaxValue, decoded[0]);
Expand Down
2 changes: 1 addition & 1 deletion src/DotNext/Buffers/Text/Hex.Unicode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static Vector256<byte> 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);

Expand Down
2 changes: 1 addition & 1 deletion src/DotNext/Buffers/Text/Hex.Utf8.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static Vector256<byte> 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);

Expand Down
2 changes: 1 addition & 1 deletion src/DotNext/Buffers/Text/Hex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<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<byte> CharToNibbleLookupTable =>
[
Expand Down

0 comments on commit ecdafa3

Please sign in to comment.