Skip to content

Commit

Permalink
bit faster 6 nibble lenght paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Scooletz committed Aug 22, 2024
1 parent 192f7b0 commit f3b16f8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Paprika/Data/SlottedArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ public static bool TryReadFrom(scoped in Span<byte> actual, in NibblePath key, o

if (key.Length == PathLengthOf2 &&
(first & DoubleEvenNibbleCaseByteMask) == DoubleEvenNibbleCaseByteMaskValue &&
first == (key.FirstNibble << NibblePath.NibbleShift) + key.GetAt(1))
first == key.UnsafeSpan)
{
leftover = actual[DoubleEvenNibbleCaseByteCount..];
return true;
Expand Down Expand Up @@ -552,9 +552,9 @@ public static Span<byte> Write(in NibblePath key, in Span<byte> destination)
return destination[SingleNibbleLength..];
}

if (key.Length == PathLengthOf2 && (key.FirstNibble & DoubleEvenNibbleCaseFirstNibbleMask) == DoubleEvenNibbleCaseFirstNibbleMaskValue)
if (key.Length == PathLengthOf2 && (key.UnsafeSpan & DoubleEvenNibbleCaseByteMask) == DoubleEvenNibbleCaseByteMaskValue)
{
destination[0] = (byte)((key.FirstNibble << NibblePath.NibbleShift) + key.GetAt(1));
destination[0] = key.UnsafeSpan;
return destination[DoubleEvenNibbleCaseByteCount..];
}

Expand Down

0 comments on commit f3b16f8

Please sign in to comment.