Skip to content

Commit 5003d67

Browse files
committed
Merge branch 'main' of github.com:simdutf/SimdBase64
2 parents d58cb73 + 7fda96d commit 5003d67

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

src/Base64Scalar.cs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ public static int MaximalBinaryLengthFromBase64Scalar<T>(ReadOnlySpan<T> input)
6363

6464
public unsafe static OperationStatus DecodeFromBase64Scalar(ReadOnlySpan<byte> source, Span<byte> dest, out int bytesConsumed, out int bytesWritten, bool isUrl = false)
6565
{
66-
//var toBase64 = isUrl != false ? Tables.GetToBase64UrlValue : Tables.GetToBase64Value;
67-
uint[] d0 = isUrl != false ? Base64Url.d0 : Base64Default.d0;
68-
uint[] d1 = isUrl != false ? Base64Url.d1 : Base64Default.d1;
69-
uint[] d2 = isUrl != false ? Base64Url.d2 : Base64Default.d2;
70-
uint[] d3 = isUrl != false ? Base64Url.d3 : Base64Default.d3;
66+
67+
uint[] d0 = isUrl ? Base64Url.d0 : Base64Default.d0;
68+
uint[] d1 = isUrl ? Base64Url.d1 : Base64Default.d1;
69+
uint[] d2 = isUrl ? Base64Url.d2 : Base64Default.d2;
70+
uint[] d3 = isUrl ? Base64Url.d3 : Base64Default.d3;
7171

7272
int length = source.Length;
7373

@@ -81,7 +81,7 @@ public unsafe static OperationStatus DecodeFromBase64Scalar(ReadOnlySpan<byte> s
8181
UInt32 x;
8282
uint triple;
8383
int idx;
84-
// Should be
84+
// Should be
8585
// Span<byte> buffer = stackalloc byte[4];
8686
byte[] buffer = [0, 0, 0, 0];
8787

@@ -106,7 +106,7 @@ public unsafe static OperationStatus DecodeFromBase64Scalar(ReadOnlySpan<byte> s
106106
while (idx < 4 && src < srcEnd)
107107
{
108108
char c = (char)*src;
109-
byte code = isUrl != false ? Tables.GetToBase64UrlValue(c) : Tables.GetToBase64Value(c);
109+
byte code = isUrl ? Tables.GetToBase64UrlValue(c) : Tables.GetToBase64Value(c);
110110
buffer[idx] = code;
111111

112112
if (code <= 63)
@@ -207,11 +207,11 @@ public static bool IsValidBase64Index(char b)
207207

208208
public unsafe static OperationStatus DecodeFromBase64Scalar(ReadOnlySpan<char> source, Span<byte> dest, out int bytesConsumed, out int bytesWritten, bool isUrl = false)
209209
{
210-
//var toBase64 = isUrl != false ? Tables.GetToBase64UrlValue : Tables.GetToBase64Value;
211-
uint[] d0 = isUrl != false ? Base64Url.d0 : Base64Default.d0;
212-
uint[] d1 = isUrl != false ? Base64Url.d1 : Base64Default.d1;
213-
uint[] d2 = isUrl != false ? Base64Url.d2 : Base64Default.d2;
214-
uint[] d3 = isUrl != false ? Base64Url.d3 : Base64Default.d3;
210+
211+
uint[] d0 = isUrl ? Base64Url.d0 : Base64Default.d0;
212+
uint[] d1 = isUrl ? Base64Url.d1 : Base64Default.d1;
213+
uint[] d2 = isUrl ? Base64Url.d2 : Base64Default.d2;
214+
uint[] d3 = isUrl ? Base64Url.d3 : Base64Default.d3;
215215

216216
int length = source.Length;
217217

@@ -226,7 +226,7 @@ public unsafe static OperationStatus DecodeFromBase64Scalar(ReadOnlySpan<char> s
226226
UInt32 x;
227227
uint triple;
228228
int idx;
229-
// Should be
229+
// Should be
230230
// Span<byte> buffer = stackalloc byte[4];
231231
byte[] buffer = [0, 0, 0, 0];
232232

@@ -261,7 +261,7 @@ public unsafe static OperationStatus DecodeFromBase64Scalar(ReadOnlySpan<char> s
261261
return OperationStatus.InvalidData;
262262
// Process code
263263
}
264-
byte code = isUrl != false ? Tables.GetToBase64UrlValue(c) : Tables.GetToBase64Value(c);
264+
byte code = isUrl ? Tables.GetToBase64UrlValue(c) : Tables.GetToBase64Value(c);
265265
// byte code = 1;
266266
buffer[idx] = code;
267267

@@ -359,11 +359,11 @@ public unsafe static OperationStatus DecodeFromBase64Scalar(ReadOnlySpan<char> s
359359
public unsafe static OperationStatus SafeDecodeFromBase64Scalar(ReadOnlySpan<byte> source, Span<byte> dest, out int bytesConsumed, out int bytesWritten, bool isUrl = false)
360360
{
361361

362-
//var toBase64 = isUrl != false ? Tables.GetToBase64UrlValue : Tables.GetToBase64Value;
363-
uint[] d0 = isUrl != false ? Base64Url.d0 : Base64Default.d0;
364-
uint[] d1 = isUrl != false ? Base64Url.d1 : Base64Default.d1;
365-
uint[] d2 = isUrl != false ? Base64Url.d2 : Base64Default.d2;
366-
uint[] d3 = isUrl != false ? Base64Url.d3 : Base64Default.d3;
362+
363+
uint[] d0 = isUrl ? Base64Url.d0 : Base64Default.d0;
364+
uint[] d1 = isUrl ? Base64Url.d1 : Base64Default.d1;
365+
uint[] d2 = isUrl ? Base64Url.d2 : Base64Default.d2;
366+
uint[] d3 = isUrl ? Base64Url.d3 : Base64Default.d3;
367367

368368
int length = source.Length;
369369

@@ -380,7 +380,7 @@ public unsafe static OperationStatus SafeDecodeFromBase64Scalar(ReadOnlySpan<byt
380380
uint x;
381381
uint triple;
382382
int idx;
383-
// Should be
383+
// Should be
384384
// Span<byte> buffer = stackalloc byte[4];
385385
byte[] buffer = [0, 0, 0, 0];
386386

@@ -414,7 +414,7 @@ public unsafe static OperationStatus SafeDecodeFromBase64Scalar(ReadOnlySpan<byt
414414
while (idx < 4 && src < srcEnd)
415415
{
416416
char c = (char)*src;
417-
byte code = isUrl != false ? Tables.GetToBase64UrlValue(c) : Tables.GetToBase64Value(c);
417+
byte code = isUrl ? Tables.GetToBase64UrlValue(c) : Tables.GetToBase64Value(c);
418418
buffer[idx] = code;
419419

420420
if (code <= 63)
@@ -527,11 +527,11 @@ public unsafe static OperationStatus SafeDecodeFromBase64Scalar(ReadOnlySpan<byt
527527
// like DecodeFromBase64Scalar, but it will not write past the end of the ouput buffer.
528528
public unsafe static OperationStatus SafeDecodeFromBase64Scalar(ReadOnlySpan<char> source, Span<byte> dest, out int bytesConsumed, out int bytesWritten, bool isUrl = false)
529529
{
530-
//var toBase64 = isUrl != false ? Tables.GetToBase64UrlValue : Tables.GetToBase64Value;
531-
uint[] d0 = isUrl != false ? Base64Url.d0 : Base64Default.d0;
532-
uint[] d1 = isUrl != false ? Base64Url.d1 : Base64Default.d1;
533-
uint[] d2 = isUrl != false ? Base64Url.d2 : Base64Default.d2;
534-
uint[] d3 = isUrl != false ? Base64Url.d3 : Base64Default.d3;
530+
531+
uint[] d0 = isUrl ? Base64Url.d0 : Base64Default.d0;
532+
uint[] d1 = isUrl ? Base64Url.d1 : Base64Default.d1;
533+
uint[] d2 = isUrl ? Base64Url.d2 : Base64Default.d2;
534+
uint[] d3 = isUrl ? Base64Url.d3 : Base64Default.d3;
535535

536536
int length = source.Length;
537537

@@ -549,7 +549,7 @@ public unsafe static OperationStatus SafeDecodeFromBase64Scalar(ReadOnlySpan<cha
549549
uint x;
550550
uint triple;
551551
int idx;
552-
// Should be
552+
// Should be
553553
// Span<byte> buffer = stackalloc byte[4];
554554
byte[] buffer = [0, 0, 0, 0];
555555

@@ -583,7 +583,7 @@ public unsafe static OperationStatus SafeDecodeFromBase64Scalar(ReadOnlySpan<cha
583583
while (idx < 4 && src < srcEnd)
584584
{
585585
char c = (char)*src;
586-
byte code = isUrl != false ? Tables.GetToBase64UrlValue(c) : Tables.GetToBase64Value(c);
586+
byte code = isUrl ? Tables.GetToBase64UrlValue(c) : Tables.GetToBase64Value(c);
587587
buffer[idx] = code;
588588

589589
if (code <= 63)
@@ -908,7 +908,7 @@ public unsafe static OperationStatus SafeBase64ToBinaryWithWhiteSpace(ReadOnlySp
908908

909909
if (r == OperationStatus.Done && paddingCharacts > 0)
910910
{
911-
// additional checks:
911+
// additional checks:
912912
if ((remainingOut.Length % 3 == 0) || ((remainingOut.Length % 3) + 1 + paddingCharacts != 4))
913913
{
914914
r = OperationStatus.InvalidData;
@@ -1007,7 +1007,7 @@ public unsafe static OperationStatus SafeBase64ToBinaryWithWhiteSpace(ReadOnlySp
10071007

10081008
if (r == OperationStatus.Done && paddingCharacts > 0)
10091009
{
1010-
// additional checks:
1010+
// additional checks:
10111011
if ((remainingOut.Length % 3 == 0) || ((remainingOut.Length % 3) + 1 + paddingCharacts != 4))
10121012
{
10131013
r = OperationStatus.InvalidData;

0 commit comments

Comments
 (0)