Skip to content

Commit 9638ff6

Browse files
committed
don't alloc on each for each stream
1 parent 76f6708 commit 9638ff6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

MurmurHash/MurmurOutputStream.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ namespace Murmur
99
/// </summary>
1010
public class MurmurOutputStream : Stream
1111
{
12+
static readonly byte[] DEFAULT_FINAL_TRANFORM = new byte[0];
13+
1214
readonly Stream UnderlyingStream;
1315
readonly HashAlgorithm Algorithm;
1416
public MurmurOutputStream(Stream underlyingStream, uint seed = 0, bool managed = true, AlgorithmType type = AlgorithmType.Murmur128, AlgorithmPreference preference = AlgorithmPreference.Auto)
@@ -19,7 +21,7 @@ public MurmurOutputStream(Stream underlyingStream, uint seed = 0, bool managed =
1921
: (HashAlgorithm)MurmurHash.Create128(seed, managed, preference);
2022
}
2123

22-
public byte[] Hash { get { Algorithm.TransformFinalBlock(new byte[0], 0, 0); return Algorithm.Hash; } }
24+
public byte[] Hash { get { Algorithm.TransformFinalBlock(DEFAULT_FINAL_TRANFORM, 0, 0); return Algorithm.Hash; } }
2325
public override bool CanRead { get { return false; } }
2426
public override bool CanSeek { get { return false; } }
2527
public override bool CanWrite { get { return true; } }

0 commit comments

Comments
 (0)