Skip to content

Commit 88fb4b8

Browse files
teo-tsirpanisoleg-st
authored andcommitted
Avoid calling GetArrayPointer whenever possible.
The condition was updated to .NET 7 or greater, because the necessary API was introduced then. We cannot convert arrays of native integers or non-primitive structs.
1 parent 20c43fa commit 88fb4b8

File tree

9 files changed

+15
-15
lines changed

9 files changed

+15
-15
lines changed

src/ZstdSharp/Unsafe/Bitstream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace ZstdSharp.Unsafe
1010
{
1111
public static unsafe partial class Methods
1212
{
13-
#if NET8_0_OR_GREATER
13+
#if NET7_0_OR_GREATER
1414
private static ReadOnlySpan<uint> Span_BIT_mask => new uint[32]
1515
{
1616
0,

src/ZstdSharp/Unsafe/FseCompress.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ private static nuint FSE_normalizeM2(short* norm, uint tableLog, uint* count, nu
446446
return 0;
447447
}
448448

449-
#if NET8_0_OR_GREATER
449+
#if NET7_0_OR_GREATER
450450
private static ReadOnlySpan<uint> Span_rtbTable => new uint[8]
451451
{
452452
0,

src/ZstdSharp/Unsafe/ZstdCompress.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2015,7 +2015,7 @@ public static nuint ZSTD_estimateCCtxSize_usingCParams(ZSTD_compressionParameter
20152015
}
20162016
}
20172017

2018-
#if NET8_0_OR_GREATER
2018+
#if NET7_0_OR_GREATER
20192019
private static ReadOnlySpan<ulong> Span_srcSizeTiers => new ulong[4]
20202020
{
20212021
16 * (1 << 10),

src/ZstdSharp/Unsafe/ZstdCompressSequences.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace ZstdSharp.Unsafe
77
{
88
public static unsafe partial class Methods
99
{
10-
#if NET8_0_OR_GREATER
10+
#if NET7_0_OR_GREATER
1111
private static ReadOnlySpan<uint> Span_kInverseProbabilityLog256 => new uint[256]
1212
{
1313
0,

src/ZstdSharp/Unsafe/ZstdDecompressBlock.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ private static nuint ZSTD_decodeSeqHeaders(ZSTD_DCtx_s* dctx, int* nbSeqPtr, voi
735735
return (nuint)(ip - istart);
736736
}
737737

738-
#if NET8_0_OR_GREATER
738+
#if NET7_0_OR_GREATER
739739
private static ReadOnlySpan<uint> Span_dec32table => new uint[8]
740740
{
741741
0,
@@ -752,7 +752,7 @@ private static nuint ZSTD_decodeSeqHeaders(ZSTD_DCtx_s* dctx, int* nbSeqPtr, voi
752752

753753
private static readonly uint* dec32table = GetArrayPointer(new uint[8] { 0, 1, 2, 1, 4, 4, 4, 4 });
754754
#endif
755-
#if NET8_0_OR_GREATER
755+
#if NET7_0_OR_GREATER
756756
private static ReadOnlySpan<int> Span_dec64table => new int[8]
757757
{
758758
8,

src/ZstdSharp/Unsafe/ZstdDecompressInternal.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace ZstdSharp.Unsafe
77
{
88
public static unsafe partial class Methods
99
{
10-
#if NET8_0_OR_GREATER
10+
#if NET7_0_OR_GREATER
1111
private static ReadOnlySpan<uint> Span_LL_base => new uint[36]
1212
{
1313
0,
@@ -52,7 +52,7 @@ public static unsafe partial class Methods
5252

5353
private static readonly uint* LL_base = GetArrayPointer(new uint[36] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 22, 24, 28, 32, 40, 48, 64, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000, 0x10000 });
5454
#endif
55-
#if NET8_0_OR_GREATER
55+
#if NET7_0_OR_GREATER
5656
private static ReadOnlySpan<uint> Span_OF_base => new uint[32]
5757
{
5858
0,
@@ -134,7 +134,7 @@ public static unsafe partial class Methods
134134

135135
private static readonly byte* OF_bits = GetArrayPointer(new byte[32] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 });
136136
#endif
137-
#if NET8_0_OR_GREATER
137+
#if NET7_0_OR_GREATER
138138
private static ReadOnlySpan<uint> Span_ML_base => new uint[53]
139139
{
140140
3,

src/ZstdSharp/Unsafe/ZstdInternal.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace ZstdSharp.Unsafe
1313
{
1414
public static unsafe partial class Methods
1515
{
16-
#if NET8_0_OR_GREATER
16+
#if NET7_0_OR_GREATER
1717
private static ReadOnlySpan<uint> Span_repStartValue => new uint[3]
1818
{
1919
1,
@@ -73,7 +73,7 @@ public static unsafe partial class Methods
7373

7474
private static readonly byte* LL_bits = GetArrayPointer(new byte[36] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 });
7575
#endif
76-
#if NET8_0_OR_GREATER
76+
#if NET7_0_OR_GREATER
7777
private static ReadOnlySpan<short> Span_LL_defaultNorm => new short[36]
7878
{
7979
4,
@@ -244,7 +244,7 @@ public static unsafe partial class Methods
244244
private static readonly short* ML_defaultNorm = GetArrayPointer(new short[53] { 1, 4, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1), (short)(-1) });
245245
#endif
246246
private const uint ML_defaultNormLog = 6;
247-
#if NET8_0_OR_GREATER
247+
#if NET7_0_OR_GREATER
248248
private static ReadOnlySpan<short> Span_OF_defaultNorm => new short[29]
249249
{
250250
1,

src/ZstdSharp/Unsafe/ZstdLdmGeartab.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace ZstdSharp.Unsafe
66
{
77
public static unsafe partial class Methods
88
{
9-
#if NET8_0_OR_GREATER
9+
#if NET7_0_OR_GREATER
1010
private static ReadOnlySpan<ulong> Span_ZSTD_ldm_gearTab => new ulong[256]
1111
{
1212
0xf5b8f72c5f77775c,

src/ZstdSharp/Unsafe/ZstdOpt.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ private static uint ZSTD_scaleStats(uint* table, uint lastEltIndex, uint logTarg
8787
return ZSTD_downscaleStats(table, lastEltIndex, ZSTD_highbit32(factor), base_directive_e.base_1guaranteed);
8888
}
8989

90-
#if NET8_0_OR_GREATER
90+
#if NET7_0_OR_GREATER
9191
private static ReadOnlySpan<uint> Span_baseLLfreqs => new uint[36]
9292
{
9393
4,
@@ -132,7 +132,7 @@ private static uint ZSTD_scaleStats(uint* table, uint lastEltIndex, uint logTarg
132132

133133
private static readonly uint* baseLLfreqs = GetArrayPointer(new uint[36] { 4, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });
134134
#endif
135-
#if NET8_0_OR_GREATER
135+
#if NET7_0_OR_GREATER
136136
private static ReadOnlySpan<uint> Span_baseOFCfreqs => new uint[32]
137137
{
138138
6,

0 commit comments

Comments
 (0)