Skip to content

Commit d5ae337

Browse files
committed
cont
1 parent 63f1f12 commit d5ae337

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/UglyToad.PdfPig/Util/MurmurHash3.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
using System;
1818
using System.Buffers.Binary;
19+
using System.Security.Cryptography;
1920

2021
/// <summary>
2122
/// MurmurHash is a non-cryptographic hash function suitable for general hash-based lookup.
@@ -65,7 +66,11 @@ public static byte[] Compute_x86_128(ReadOnlySpan<byte> data, int len, uint seed
6566
Span<uint> hash = stackalloc uint[4];
6667
Compute_x86_128(data, len, seed, hash);
6768

69+
#if NET
70+
byte[] result = GC.AllocateUninitializedArray<byte>(16);
71+
#else
6872
byte[] result = new byte[16];
73+
#endif
6974

7075
var span = result.AsSpan();
7176

@@ -113,8 +118,12 @@ public static byte[] Compute_x64_128(ReadOnlySpan<byte> data, int len, uint seed
113118
Span<ulong> hash = stackalloc ulong[2];
114119
Compute_x64_128(data, len, seed, hash);
115120

121+
#if NET
122+
byte[] result = GC.AllocateUninitializedArray<byte>(16);
123+
#else
116124
byte[] result = new byte[16];
117-
125+
#endif
126+
118127
var span = result.AsSpan();
119128

120129
Span<byte> buffer = stackalloc byte[8];
@@ -423,6 +432,5 @@ private static void GetBytes(Span<byte> buffer, uint v)
423432

424433
BinaryPrimitives.WriteUInt32LittleEndian(buffer, v);
425434
}
426-
427435
}
428436
}

0 commit comments

Comments
 (0)