Skip to content

Commit 7fda96d

Browse files
author
Daniel Lemire
committed
cleaning
1 parent 4e1c620 commit 7fda96d

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
@@ -47,11 +47,11 @@ public static int MaximalBinaryLengthFromBase64Scalar<T>(ReadOnlySpan<T> input)
4747

4848
public unsafe static OperationStatus DecodeFromBase64Scalar(ReadOnlySpan<byte> source, Span<byte> dest, out int bytesConsumed, out int bytesWritten, bool isUrl = false)
4949
{
50-
//var toBase64 = isUrl != false ? Tables.GetToBase64UrlValue : Tables.GetToBase64Value;
51-
uint[] d0 = isUrl != false ? Base64Url.d0 : Base64Default.d0;
52-
uint[] d1 = isUrl != false ? Base64Url.d1 : Base64Default.d1;
53-
uint[] d2 = isUrl != false ? Base64Url.d2 : Base64Default.d2;
54-
uint[] d3 = isUrl != false ? Base64Url.d3 : Base64Default.d3;
50+
51+
uint[] d0 = isUrl ? Base64Url.d0 : Base64Default.d0;
52+
uint[] d1 = isUrl ? Base64Url.d1 : Base64Default.d1;
53+
uint[] d2 = isUrl ? Base64Url.d2 : Base64Default.d2;
54+
uint[] d3 = isUrl ? Base64Url.d3 : Base64Default.d3;
5555

5656
int length = source.Length;
5757

@@ -65,7 +65,7 @@ public unsafe static OperationStatus DecodeFromBase64Scalar(ReadOnlySpan<byte> s
6565
UInt32 x;
6666
uint triple;
6767
int idx;
68-
// Should be
68+
// Should be
6969
// Span<byte> buffer = stackalloc byte[4];
7070
byte[] buffer = [0, 0, 0, 0];
7171

@@ -90,7 +90,7 @@ public unsafe static OperationStatus DecodeFromBase64Scalar(ReadOnlySpan<byte> s
9090
while (idx < 4 && src < srcEnd)
9191
{
9292
char c = (char)*src;
93-
byte code = isUrl != false ? Tables.GetToBase64UrlValue(c) : Tables.GetToBase64Value(c);
93+
byte code = isUrl ? Tables.GetToBase64UrlValue(c) : Tables.GetToBase64Value(c);
9494
buffer[idx] = code;
9595

9696
if (code <= 63)
@@ -193,11 +193,11 @@ public static bool IsValidBase64Index(char b)
193193

194194
public unsafe static OperationStatus DecodeFromBase64Scalar(ReadOnlySpan<char> source, Span<byte> dest, out int bytesConsumed, out int bytesWritten, bool isUrl = false)
195195
{
196-
//var toBase64 = isUrl != false ? Tables.GetToBase64UrlValue : Tables.GetToBase64Value;
197-
uint[] d0 = isUrl != false ? Base64Url.d0 : Base64Default.d0;
198-
uint[] d1 = isUrl != false ? Base64Url.d1 : Base64Default.d1;
199-
uint[] d2 = isUrl != false ? Base64Url.d2 : Base64Default.d2;
200-
uint[] d3 = isUrl != false ? Base64Url.d3 : Base64Default.d3;
196+
197+
uint[] d0 = isUrl ? Base64Url.d0 : Base64Default.d0;
198+
uint[] d1 = isUrl ? Base64Url.d1 : Base64Default.d1;
199+
uint[] d2 = isUrl ? Base64Url.d2 : Base64Default.d2;
200+
uint[] d3 = isUrl ? Base64Url.d3 : Base64Default.d3;
201201

202202
int length = source.Length;
203203

@@ -212,7 +212,7 @@ public unsafe static OperationStatus DecodeFromBase64Scalar(ReadOnlySpan<char> s
212212
UInt32 x;
213213
uint triple;
214214
int idx;
215-
// Should be
215+
// Should be
216216
// Span<byte> buffer = stackalloc byte[4];
217217
byte[] buffer = [0, 0, 0, 0];
218218

@@ -247,7 +247,7 @@ public unsafe static OperationStatus DecodeFromBase64Scalar(ReadOnlySpan<char> s
247247
return OperationStatus.InvalidData;
248248
// Process code
249249
}
250-
byte code = isUrl != false ? Tables.GetToBase64UrlValue(c) : Tables.GetToBase64Value(c);
250+
byte code = isUrl ? Tables.GetToBase64UrlValue(c) : Tables.GetToBase64Value(c);
251251
// byte code = 1;
252252
buffer[idx] = code;
253253

@@ -347,11 +347,11 @@ public unsafe static OperationStatus DecodeFromBase64Scalar(ReadOnlySpan<char> s
347347
public unsafe static OperationStatus SafeDecodeFromBase64Scalar(ReadOnlySpan<byte> source, Span<byte> dest, out int bytesConsumed, out int bytesWritten, bool isUrl = false)
348348
{
349349

350-
//var toBase64 = isUrl != false ? Tables.GetToBase64UrlValue : Tables.GetToBase64Value;
351-
uint[] d0 = isUrl != false ? Base64Url.d0 : Base64Default.d0;
352-
uint[] d1 = isUrl != false ? Base64Url.d1 : Base64Default.d1;
353-
uint[] d2 = isUrl != false ? Base64Url.d2 : Base64Default.d2;
354-
uint[] d3 = isUrl != false ? Base64Url.d3 : Base64Default.d3;
350+
351+
uint[] d0 = isUrl ? Base64Url.d0 : Base64Default.d0;
352+
uint[] d1 = isUrl ? Base64Url.d1 : Base64Default.d1;
353+
uint[] d2 = isUrl ? Base64Url.d2 : Base64Default.d2;
354+
uint[] d3 = isUrl ? Base64Url.d3 : Base64Default.d3;
355355

356356
int length = source.Length;
357357

@@ -368,7 +368,7 @@ public unsafe static OperationStatus SafeDecodeFromBase64Scalar(ReadOnlySpan<byt
368368
uint x;
369369
uint triple;
370370
int idx;
371-
// Should be
371+
// Should be
372372
// Span<byte> buffer = stackalloc byte[4];
373373
byte[] buffer = [0, 0, 0, 0];
374374

@@ -402,7 +402,7 @@ public unsafe static OperationStatus SafeDecodeFromBase64Scalar(ReadOnlySpan<byt
402402
while (idx < 4 && src < srcEnd)
403403
{
404404
char c = (char)*src;
405-
byte code = isUrl != false ? Tables.GetToBase64UrlValue(c) : Tables.GetToBase64Value(c);
405+
byte code = isUrl ? Tables.GetToBase64UrlValue(c) : Tables.GetToBase64Value(c);
406406
buffer[idx] = code;
407407

408408
if (code <= 63)
@@ -517,11 +517,11 @@ public unsafe static OperationStatus SafeDecodeFromBase64Scalar(ReadOnlySpan<byt
517517
// like DecodeFromBase64Scalar, but it will not write past the end of the ouput buffer.
518518
public unsafe static OperationStatus SafeDecodeFromBase64Scalar(ReadOnlySpan<char> source, Span<byte> dest, out int bytesConsumed, out int bytesWritten, bool isUrl = false)
519519
{
520-
//var toBase64 = isUrl != false ? Tables.GetToBase64UrlValue : Tables.GetToBase64Value;
521-
uint[] d0 = isUrl != false ? Base64Url.d0 : Base64Default.d0;
522-
uint[] d1 = isUrl != false ? Base64Url.d1 : Base64Default.d1;
523-
uint[] d2 = isUrl != false ? Base64Url.d2 : Base64Default.d2;
524-
uint[] d3 = isUrl != false ? Base64Url.d3 : Base64Default.d3;
520+
521+
uint[] d0 = isUrl ? Base64Url.d0 : Base64Default.d0;
522+
uint[] d1 = isUrl ? Base64Url.d1 : Base64Default.d1;
523+
uint[] d2 = isUrl ? Base64Url.d2 : Base64Default.d2;
524+
uint[] d3 = isUrl ? Base64Url.d3 : Base64Default.d3;
525525

526526
int length = source.Length;
527527

@@ -539,7 +539,7 @@ public unsafe static OperationStatus SafeDecodeFromBase64Scalar(ReadOnlySpan<cha
539539
uint x;
540540
uint triple;
541541
int idx;
542-
// Should be
542+
// Should be
543543
// Span<byte> buffer = stackalloc byte[4];
544544
byte[] buffer = [0, 0, 0, 0];
545545

@@ -573,7 +573,7 @@ public unsafe static OperationStatus SafeDecodeFromBase64Scalar(ReadOnlySpan<cha
573573
while (idx < 4 && src < srcEnd)
574574
{
575575
char c = (char)*src;
576-
byte code = isUrl != false ? Tables.GetToBase64UrlValue(c) : Tables.GetToBase64Value(c);
576+
byte code = isUrl ? Tables.GetToBase64UrlValue(c) : Tables.GetToBase64Value(c);
577577
buffer[idx] = code;
578578

579579
if (code <= 63)
@@ -900,7 +900,7 @@ public unsafe static OperationStatus SafeBase64ToBinaryWithWhiteSpace(ReadOnlySp
900900

901901
if (r == OperationStatus.Done && paddingCharacts > 0)
902902
{
903-
// additional checks:
903+
// additional checks:
904904
if ((remainingOut.Length % 3 == 0) || ((remainingOut.Length % 3) + 1 + paddingCharacts != 4))
905905
{
906906
r = OperationStatus.InvalidData;
@@ -999,7 +999,7 @@ public unsafe static OperationStatus SafeBase64ToBinaryWithWhiteSpace(ReadOnlySp
999999

10001000
if (r == OperationStatus.Done && paddingCharacts > 0)
10011001
{
1002-
// additional checks:
1002+
// additional checks:
10031003
if ((remainingOut.Length % 3 == 0) || ((remainingOut.Length % 3) + 1 + paddingCharacts != 4))
10041004
{
10051005
r = OperationStatus.InvalidData;

0 commit comments

Comments
 (0)