Skip to content

Commit

Permalink
replace BitConverter (#2522)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim8y authored Jul 10, 2021
1 parent f9b0b3b commit 1bcbc6b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/neo/Cryptography/Murmur128.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ protected override byte[] HashFinal()
H1 += H2;
H2 += H1;

var buffer = new byte[16];
Array.Copy(BitConverter.GetBytes(H1), 0, buffer, 0, 8);
Array.Copy(BitConverter.GetBytes(H2), 0, buffer, 8, 8);
var buffer = new byte[sizeof(ulong) * 2];
Span<byte> bytes = buffer;

BinaryPrimitives.WriteUInt64LittleEndian(bytes, H1);
BinaryPrimitives.WriteUInt64LittleEndian(bytes[sizeof(ulong)..], H2);

return buffer;
}
Expand All @@ -125,7 +127,6 @@ private static ulong RotateLeft(ulong x, byte n)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static ulong FMix(ulong h)
{
// pipelining friendly algorithm
h = (h ^ (h >> 33)) * 0xff51afd7ed558ccd;
h = (h ^ (h >> 33)) * 0xc4ceb9fe1a85ec53;

Expand Down

0 comments on commit 1bcbc6b

Please sign in to comment.