4
4
using System . Diagnostics ;
5
5
using System . Runtime . CompilerServices ;
6
6
using System . Runtime . InteropServices ;
7
- #if NETCOREAPP
7
+ #if NET
8
8
using System . Runtime . Intrinsics . Arm ;
9
9
using System . Runtime . Intrinsics . X86 ;
10
10
using System . Runtime . Intrinsics ;
@@ -14,10 +14,6 @@ namespace System.Buffers.Text
14
14
{
15
15
internal static partial class Base64Helper
16
16
{
17
- #pragma warning disable CA1805 // Member 's_base64ByteDecoder' is explicitly initialized to its default value
18
- internal static Base64DecoderByte s_base64ByteDecoder = default ;
19
- #pragma warning restore CA1805
20
-
21
17
internal static unsafe OperationStatus DecodeFrom < TBase64Decoder , T > ( TBase64Decoder decoder , ReadOnlySpan < T > source , Span < byte > bytes ,
22
18
out int bytesConsumed , out int bytesWritten , bool isFinalBlock , bool ignoreWhiteSpace )
23
19
where TBase64Decoder : IBase64Decoder < T >
@@ -50,7 +46,7 @@ internal static unsafe OperationStatus DecodeFrom<TBase64Decoder, T>(TBase64Deco
50
46
T * srcEnd = srcBytes + ( uint ) srcLength ;
51
47
T * srcMax = srcBytes + ( uint ) maxSrcLength ;
52
48
53
- #if NETCOREAPP
49
+ #if NET
54
50
if ( maxSrcLength >= 24 )
55
51
{
56
52
T * end = srcMax - 88 ;
@@ -112,7 +108,7 @@ internal static unsafe OperationStatus DecodeFrom<TBase64Decoder, T>(TBase64Deco
112
108
// This should never overflow since destLength here is less than int.MaxValue / 4 * 3 (i.e. 1610612733)
113
109
// Therefore, (destLength / 3) * 4 will always be less than 2147483641
114
110
Debug . Assert ( destLength < ( int . MaxValue / 4 * 3 ) ) ;
115
- #if NETCOREAPP
111
+ #if NET
116
112
( maxSrcLength , int remainder ) = int . DivRem ( destLength , 3 ) ;
117
113
maxSrcLength *= 4 ;
118
114
#else
@@ -643,13 +639,13 @@ private static OperationStatus DecodeWithWhiteSpaceFromUtf8InPlace<TBase64Decode
643
639
return status ;
644
640
}
645
641
646
- #if NETCOREAPP
642
+ #if NET
647
643
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
648
644
[ CompExactlyDependsOn ( typeof ( Avx512BW ) ) ]
649
645
[ CompExactlyDependsOn ( typeof ( Avx512Vbmi ) ) ]
650
646
private static unsafe void Avx512Decode < TBase64Decoder , T > ( TBase64Decoder decoder , ref T * srcBytes , ref byte * destBytes , T * srcEnd , int sourceLength , int destLength , T * srcStart , byte * destStart )
651
- where TBase64Decoder : IBase64Decoder < T >
652
- where T : unmanaged
647
+ where TBase64Decoder : IBase64Decoder < T >
648
+ where T : unmanaged
653
649
{
654
650
// Reference for VBMI implementation : https://github.com/WojciechMula/base64simd/tree/master/decode
655
651
// If we have AVX512 support, pick off 64 bytes at a time for as long as we can,
@@ -1243,20 +1239,15 @@ internal static bool IsWhiteSpace(int value)
1243
1239
1244
1240
public uint AdvSimdLutTwo3Uint1 => 0x1B1AFFFF ;
1245
1241
1246
- public int GetMaxDecodedLength ( int utf8Length ) =>
1247
- #if NETCOREAPP
1248
- Base64 . GetMaxDecodedFromUtf8Length ( utf8Length ) ;
1249
- #else
1250
- 0 ;
1251
- #endif
1242
+ public int GetMaxDecodedLength ( int utf8Length ) => Base64 . GetMaxDecodedFromUtf8Length ( utf8Length ) ;
1252
1243
1253
1244
public bool IsInvalidLength ( int bufferLength ) => bufferLength % 4 != 0 ; // only decode input if it is a multiple of 4
1254
1245
1255
1246
public bool IsValidPadding ( uint padChar ) => padChar == EncodingPad ;
1256
1247
1257
1248
public int SrcLength ( bool _ , int utf8Length ) => utf8Length & ~ 0x3 ; // only decode input up to the closest multiple of 4.
1258
1249
1259
- #if NETCOREAPP
1250
+ #if NET
1260
1251
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
1261
1252
[ CompExactlyDependsOn ( typeof ( AdvSimd . Arm64 ) ) ]
1262
1253
[ CompExactlyDependsOn ( typeof ( Ssse3 ) ) ]
0 commit comments