Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed mismatched framework directives for vectorized memory move #635

Merged
merged 4 commits into from Aug 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/ICSharpCode.SharpZipLib/BZip2/BZip2InputStream.cs
@@ -1,3 +1,7 @@
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#define VECTORIZE_MEMORY_MOVE
#endif

using ICSharpCode.SharpZipLib.Checksum;
using System;
using System.IO;
Expand All @@ -19,9 +23,9 @@ public class BZip2InputStream : Stream
private const int NO_RAND_PART_B_STATE = 6;
private const int NO_RAND_PART_C_STATE = 7;

#if NETSTANDARD2_1
#if VECTORIZE_MEMORY_MOVE
private static readonly int VectorSize = System.Numerics.Vector<byte>.Count;
#endif
#endif // VECTORIZE_MEMORY_MOVE

#endregion Constants

Expand Down Expand Up @@ -717,7 +721,7 @@ cache misses.

var j = nextSym - 1;

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

while(j > 0)
{
Expand Down