Skip to content

Commit cd5310f

Browse files
fix(bzip2): use explicit feature defs for vectorized memory move (#635)
* Fixed mismatched framework directives for vectorized memory move Co-authored-by: nils måsén <[email protected]>
1 parent f04d973 commit cd5310f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/ICSharpCode.SharpZipLib/BZip2/BZip2InputStream.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
2+
#define VECTORIZE_MEMORY_MOVE
3+
#endif
4+
15
using ICSharpCode.SharpZipLib.Checksum;
26
using System;
37
using System.IO;
@@ -19,9 +23,9 @@ public class BZip2InputStream : Stream
1923
private const int NO_RAND_PART_B_STATE = 6;
2024
private const int NO_RAND_PART_C_STATE = 7;
2125

22-
#if NETSTANDARD2_1
26+
#if VECTORIZE_MEMORY_MOVE
2327
private static readonly int VectorSize = System.Numerics.Vector<byte>.Count;
24-
#endif
28+
#endif // VECTORIZE_MEMORY_MOVE
2529

2630
#endregion Constants
2731

@@ -717,7 +721,7 @@ cache misses.
717721

718722
var j = nextSym - 1;
719723

720-
#if !NETSTANDARD2_0 && !NETFRAMEWORK
724+
#if VECTORIZE_MEMORY_MOVE
721725
// This is vectorized memory move. Going from the back, we're taking chunks of array
722726
// and write them at the new location shifted by one. Since chunks are VectorSize long,
723727
// at the end we have to move "tail" (or head actually) of the array using a plain loop.
@@ -729,7 +733,7 @@ cache misses.
729733
arrayPart.CopyTo(yy, j - VectorSize + 1);
730734
j -= VectorSize;
731735
}
732-
#endif
736+
#endif // VECTORIZE_MEMORY_MOVE
733737

734738
while(j > 0)
735739
{

0 commit comments

Comments
 (0)