2
2
// Licensed under the Apache License, Version 2.0.
3
3
// https://github.com/SixLabors/ImageSharp/blob/master/src/ImageSharp/Formats/Png/Zlib/Adler32.cs
4
4
5
-
6
- #if NETCOREAPP
7
5
using System ;
8
-
9
- #if ! NETCOREAPP2_1
6
+ #if ! NET45 && ! NET461 && ! NET471 && ! NETSTANDARD1_3 && ! NETSTANDARD2_0 && ! NETSTANDARD2_1 && ! NETCOREAPP2_1
10
7
using System . Runtime . Intrinsics ;
11
8
using System . Runtime . Intrinsics . X86 ;
12
9
#endif
13
10
14
- #endif
15
-
16
11
#pragma warning disable IDE0007 // Use implicit type
17
12
18
13
namespace MySqlConnector . Utilities
@@ -34,7 +29,7 @@ internal static class Adler32
34
29
// NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1
35
30
private const uint NMAX = 5552 ;
36
31
37
- #if NETCOREAPP && ! NETCOREAPP2_1
32
+ #if ! NET45 && ! NET461 && ! NET471 && ! NETSTANDARD1_3 && ! NETSTANDARD2_0 && ! NETSTANDARD2_1 && ! NETCOREAPP2_1
38
33
private const int MinBufferSize = 64 ;
39
34
40
35
// The C# compiler emits this as a compile-time constant embedded in the PE file.
@@ -52,18 +47,14 @@ internal static class Adler32
52
47
/// <param name="offset"></param>
53
48
/// <param name="length"></param>
54
49
/// <returns>The <see cref="uint"/>.</returns>
55
- #if NETCOREAPP
56
50
public static uint Calculate ( ReadOnlySpan < byte > buffer , uint offset , uint length )
57
- #else
58
- public static uint Calculate ( byte [ ] buffer , uint offset , uint length )
59
- #endif
60
51
{
61
52
if ( buffer . Length == 0 )
62
53
{
63
54
return SeedValue ;
64
55
}
65
56
66
- #if NETCOREAPP && ! NETCOREAPP2_1
57
+ #if ! NET45 && ! NET461 && ! NET471 && ! NETSTANDARD1_3 && ! NETSTANDARD2_0 && ! NETSTANDARD2_1 && ! NETCOREAPP2_1
67
58
if ( Ssse3 . IsSupported && buffer . Length >= MinBufferSize )
68
59
{
69
60
return CalculateSse ( buffer , offset , length ) ;
@@ -74,7 +65,7 @@ public static uint Calculate(byte[] buffer, uint offset, uint length)
74
65
}
75
66
76
67
77
- #if NETCOREAPP && ! NETCOREAPP2_1
68
+ #if ! NET45 && ! NET461 && ! NET471 && ! NETSTANDARD1_3 && ! NETSTANDARD2_0 && ! NETSTANDARD2_1 && ! NETCOREAPP2_1
78
69
// Based on https://github.com/chromium/chromium/blob/master/third_party/zlib/adler32_simd.c
79
70
private static unsafe uint CalculateSse ( ReadOnlySpan < byte > buffer , uint offset , uint length )
80
71
{
@@ -202,11 +193,7 @@ private static unsafe uint CalculateSse(ReadOnlySpan<byte> buffer, uint offset,
202
193
}
203
194
#endif
204
195
205
- #if NETCOREAPP
206
196
private static unsafe uint CalculateScalar ( ReadOnlySpan < byte > buffer , uint offset , uint length )
207
- #else
208
- private static unsafe uint CalculateScalar ( byte [ ] buffer , uint offset , uint length )
209
- #endif
210
197
{
211
198
uint s1 = SeedValue & 0xFFFF ;
212
199
uint s2 = ( SeedValue >> 16 ) & 0xFFFF ;
0 commit comments