Skip to content

Commit

Permalink
Added: GC.AllocateUninitializedArray for non-zeroing array alloc.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewer56 committed Oct 2, 2021
1 parent 7c9b629 commit 12425b5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/VCDiff/Encoders/BlockHash.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using VCDiff.Shared;
Expand Down Expand Up @@ -56,9 +56,17 @@ public BlockHash(ByteBuffer sin, int offset, RollingHash hasher, int blockSize =
this.blocksCount = source.Length / blockSize;

hashTableMask = (ulong)tableSize - 1;

#if NET5_0
hashTable = GC.AllocateUninitializedArray<long>((int) tableSize);
nextBlockTable = GC.AllocateUninitializedArray<long>((int) blocksCount);
lastBlockTable = GC.AllocateUninitializedArray<long>((int) blocksCount);
#else
hashTable = new long[tableSize];
nextBlockTable = new long[blocksCount];
lastBlockTable = new long[blocksCount];
#endif

lastBlockAdded = -1;
SetTablesToInvalid();
}
Expand Down

0 comments on commit 12425b5

Please sign in to comment.