Skip to content

Commit ca1c240

Browse files
committed
making the tables internal
1 parent 1abd80d commit ca1c240

File tree

4 files changed

+48
-30
lines changed

4 files changed

+48
-30
lines changed

src/Base64Tables.cs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace SimdBase64
44
{
5-
public static class Base64Default
5+
internal static class Base64Default
66
{
77

8-
public static readonly char[] e0 = new char[256] {
8+
internal static readonly char[] e0 = new char[256] {
99
'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'C', 'C', 'C', 'C', 'D', 'D', 'D',
1010
'D', 'E', 'E', 'E', 'E', 'F', 'F', 'F', 'F', 'G', 'G', 'G', 'G', 'H', 'H',
1111
'H', 'H', 'I', 'I', 'I', 'I', 'J', 'J', 'J', 'J', 'K', 'K', 'K', 'K', 'L',
@@ -25,7 +25,7 @@ public static class Base64Default
2525
'8', '8', '8', '8', '9', '9', '9', '9', '+', '+', '+', '+', '/', '/', '/',
2626
'/'};
2727

28-
public static readonly char[] e1 = new char[256] {
28+
internal static readonly char[] e1 = new char[256] {
2929
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
3030
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
3131
'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
@@ -45,7 +45,7 @@ public static class Base64Default
4545
'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+',
4646
'/'};
4747

48-
public static readonly char[] e2 = new char[256] {
48+
internal static readonly char[] e2 = new char[256] {
4949
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
5050
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
5151
'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
@@ -65,7 +65,7 @@ public static class Base64Default
6565
'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+',
6666
'/'};
6767

68-
public static readonly uint[] d0 = new uint[256] {
68+
internal static readonly uint[] d0 = new uint[256] {
6969
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
7070
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
7171
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
@@ -110,7 +110,7 @@ public static class Base64Default
110110
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
111111
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff};
112112

113-
public static readonly uint[] d1 = new uint[256] {
113+
internal static readonly uint[] d1 = new uint[256] {
114114
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
115115
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
116116
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
@@ -155,7 +155,7 @@ public static class Base64Default
155155
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
156156
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff};
157157

158-
public static readonly uint[] d2 = new uint[256] {
158+
internal static readonly uint[] d2 = new uint[256] {
159159
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
160160
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
161161
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
@@ -200,7 +200,7 @@ public static class Base64Default
200200
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
201201
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff};
202202

203-
public static readonly uint[] d3 = new uint[256] {
203+
internal static readonly uint[] d3 = new uint[256] {
204204
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
205205
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
206206
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
@@ -246,10 +246,10 @@ public static class Base64Default
246246
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff};
247247
}
248248

249-
public static class Base64Url
249+
internal static class Base64Url
250250
{
251251

252-
public static readonly char[] e0 = new char[256] {
252+
internal static readonly char[] e0 = new char[256] {
253253
'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'C', 'C', 'C', 'C', 'D', 'D', 'D',
254254
'D', 'E', 'E', 'E', 'E', 'F', 'F', 'F', 'F', 'G', 'G', 'G', 'G', 'H', 'H',
255255
'H', 'H', 'I', 'I', 'I', 'I', 'J', 'J', 'J', 'J', 'K', 'K', 'K', 'K', 'L',
@@ -269,7 +269,7 @@ public static class Base64Url
269269
'8', '8', '8', '8', '9', '9', '9', '9', '-', '-', '-', '-', '_', '_', '_',
270270
'_'};
271271

272-
public static readonly char[] e1 = new char[256] {
272+
internal static readonly char[] e1 = new char[256] {
273273
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
274274
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
275275
'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
@@ -289,7 +289,7 @@ public static class Base64Url
289289
'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-',
290290
'_'};
291291

292-
public static readonly char[] e2 = new char[256] {
292+
internal static readonly char[] e2 = new char[256] {
293293
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
294294
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
295295
'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
@@ -309,7 +309,7 @@ public static class Base64Url
309309
'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-',
310310
'_'};
311311

312-
public static readonly uint[] d0 = new uint[256] {
312+
internal static readonly uint[] d0 = new uint[256] {
313313
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
314314
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
315315
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
@@ -353,7 +353,7 @@ public static class Base64Url
353353
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
354354
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
355355
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff};
356-
public static readonly uint[] d1 = new uint[256] {
356+
internal static readonly uint[] d1 = new uint[256] {
357357
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
358358
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
359359
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
@@ -397,7 +397,7 @@ public static class Base64Url
397397
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
398398
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
399399
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff};
400-
public static readonly uint[] d2 = new uint[256] {
400+
internal static readonly uint[] d2 = new uint[256] {
401401
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
402402
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
403403
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
@@ -441,7 +441,7 @@ public static class Base64Url
441441
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
442442
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
443443
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff};
444-
public static readonly uint[] d3 = new uint[256] {
444+
internal static readonly uint[] d3 = new uint[256] {
445445
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
446446
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
447447
0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff,
@@ -488,10 +488,10 @@ public static class Base64Url
488488
}
489489

490490

491-
public static class Tables
491+
internal static class Tables
492492
{
493493

494-
public static readonly ulong[] thintableEpi8 = new ulong[256]
494+
internal static readonly ulong[] thintableEpi8 = new ulong[256]
495495
{ 0x0706050403020100, 0x0007060504030201, 0x0007060504030200,
496496
0x0000070605040302, 0x0007060504030100, 0x0000070605040301,
497497
0x0000070605040300, 0x0000000706050403, 0x0007060504020100,
@@ -580,7 +580,7 @@ public static class Tables
580580
0x0000000000000000,
581581
};
582582

583-
public static readonly byte[] pshufbCombineTable = new byte[144]
583+
internal static readonly byte[] pshufbCombineTable = new byte[144]
584584
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
585585
0x0c, 0x0d, 0x0e, 0x0f, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x08,
586586
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0xff, 0x00, 0x01, 0x02, 0x03,
@@ -595,7 +595,7 @@ public static class Tables
595595
0x0c, 0x0d, 0x0e, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
596596
};
597597

598-
public static readonly byte[] BitsSetTable256mul2 = new byte[256]
598+
internal static readonly byte[] BitsSetTable256mul2 = new byte[256]
599599
{ 0, 2, 2, 4, 2, 4, 4, 6, 2, 4, 4, 6, 4, 6, 6, 8, 2, 4, 4,
600600
6, 4, 6, 6, 8, 4, 6, 6, 8, 6, 8, 8, 10, 2, 4, 4, 6, 4, 6,
601601
6, 8, 4, 6, 6, 8, 6, 8, 8, 10, 4, 6, 6, 8, 6, 8, 8, 10, 6,
@@ -611,7 +611,7 @@ public static class Tables
611611
8, 10, 10, 12, 8, 10, 10, 12, 10, 12, 12, 14, 8, 10, 10, 12, 10, 12, 12,
612612
14, 10, 12, 12, 14, 12, 14, 14, 16};
613613

614-
public static readonly byte[] ToBase64Value = new byte[]
614+
internal static readonly byte[] ToBase64Value = new byte[]
615615
{ 255, 255, 255, 255, 255, 255, 255, 255, 255, 64, 64, 255, 64, 64, 255,
616616
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
617617
255, 255, 64, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 255,
@@ -631,7 +631,7 @@ public static class Tables
631631
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
632632
255};
633633

634-
public static readonly byte[] ToBase64UrlValue = new byte[] {
634+
internal static readonly byte[] ToBase64UrlValue = new byte[] {
635635
255, 255, 255, 255, 255, 255, 255, 255, 255, 64, 64, 255, 64, 64, 255,
636636
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
637637
255, 255, 64, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
@@ -650,7 +650,7 @@ public static class Tables
650650
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
651651
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
652652
255};
653-
public static void Validate()
653+
internal static void Validate()
654654
{
655655
byte[] toBase64Value = ToBase64Value;
656656
byte[] toBase64UrlValue = ToBase64UrlValue;

test/Base64DecodingTestsUTF16.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,18 +1164,36 @@ public void ReadmeTestSafeARMUTF16()
11641164
}
11651165

11661166

1167+
internal static readonly byte[] ToBase64Value = new byte[]
1168+
{ 255, 255, 255, 255, 255, 255, 255, 255, 255, 64, 64, 255, 64, 64, 255,
1169+
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
1170+
255, 255, 64, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 255,
1171+
255, 255, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255,
1172+
255, 255, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
1173+
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1174+
25, 255, 255, 255, 255, 255, 255, 26, 27, 28, 29, 30, 31, 32, 33,
1175+
34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
1176+
49, 50, 51, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
1177+
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
1178+
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
1179+
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
1180+
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
1181+
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
1182+
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
1183+
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
1184+
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
1185+
255};
11671186
protected void DoomedBase64AtPos0(Base64WithWhiteSpaceToBinaryFromUTF16 Base64WithWhiteSpaceToBinaryFromUTF16, DecodeFromBase64DelegateSafeFromUTF16 DecodeFromBase64DelegateSafeFromUTF16)
11681187
{
11691188
if (Base64WithWhiteSpaceToBinaryFromUTF16 == null || DecodeFromBase64DelegateSafeFromUTF16 == null || SimdBase64.Scalar.Base64.MaximalBinaryLengthFromBase64Scalar<char> == null)
11701189
{
11711190
#pragma warning disable CA2208
11721191
throw new ArgumentNullException("Unexpected null parameter");
11731192
}
1174-
11751193
List<int> positions = new List<int>();
1176-
for (int i = 0; i < Tables.ToBase64Value.Length; i++)
1194+
for (int i = 0; i < ToBase64Value.Length; i++)
11771195
{
1178-
if (Tables.ToBase64Value[i] == 255)
1196+
if (ToBase64Value[i] == 255)
11791197
{
11801198
positions.Add(i);
11811199
}

test/Base64DecodingTestsUTF8.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,9 +1227,9 @@ protected void DoomedBase64AtPos0UTF8(Base64WithWhiteSpaceToBinary Base64WithWhi
12271227
}
12281228

12291229
List<int> positions = new List<int>();
1230-
for (int i = 0; i < Tables.ToBase64Value.Length; i++)
1230+
for (int i = 0; i < ToBase64Value.Length; i++)
12311231
{
1232-
if (Tables.ToBase64Value[i] == 255)
1232+
if (ToBase64Value[i] == 255)
12331233
{
12341234
positions.Add(i);
12351235
}

test/TestHelpers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static (byte[] modifiedArray, int location) AddGarbage(
7171
do
7272
{
7373
c = (byte)gen.Next(256);
74-
} while (c == '=' || SimdBase64.Tables.ToBase64Value[c] != 255);
74+
} while (c == '=' || ToBase64Value[c] != 255);
7575
}
7676

7777
v.Insert(i, c);
@@ -112,7 +112,7 @@ public static (char[] modifiedArray, int location) AddGarbage(
112112
do
113113
{
114114
c = (char)gen.Next(256);
115-
} while (c == '=' || SimdBase64.Tables.ToBase64Value[c] != 255);
115+
} while (c == '=' || ToBase64Value[c] != 255);
116116

117117
v.Insert(i, c);
118118

0 commit comments

Comments
 (0)