Skip to content

Commit 2046ea9

Browse files
author
Daniel Lemire
committed
more inlining
1 parent 2f5926c commit 2046ea9

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/Base64Scalar.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ namespace SimdBase64
88
{
99
namespace Scalar
1010
{
11-
1211
public static class Base64
1312
{
1413
public enum Endianness
@@ -46,7 +45,7 @@ public static int MaximalBinaryLengthFromBase64Scalar<T>(ReadOnlySpan<T> input)
4645
return length / 4 * 3 + (length % 4) - 1;
4746
}
4847

49-
48+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
5049
public unsafe static OperationStatus DecodeFromBase64Scalar(ReadOnlySpan<byte> source, Span<byte> dest, out int bytesConsumed, out int bytesWritten, bool isUrl = false)
5150
{
5251

@@ -189,13 +188,13 @@ public unsafe static OperationStatus DecodeFromBase64Scalar(ReadOnlySpan<byte> s
189188
}
190189
}
191190

192-
191+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
193192
public static bool IsValidBase64Index(char b)
194193
{
195194
return b < 256;
196195
}
197196

198-
197+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
199198
public unsafe static OperationStatus DecodeFromBase64Scalar(ReadOnlySpan<char> source, Span<byte> dest, out int bytesConsumed, out int bytesWritten, bool isUrl = false)
200199
{
201200
byte[] toBase64 = isUrl != false ? Tables.ToBase64UrlValue : Tables.ToBase64Value;
@@ -347,6 +346,7 @@ public unsafe static OperationStatus DecodeFromBase64Scalar(ReadOnlySpan<char> s
347346
}
348347

349348
// like DecodeFromBase64Scalar, but it will not write past the end of the ouput buffer.
349+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
350350
public unsafe static OperationStatus SafeDecodeFromBase64Scalar(ReadOnlySpan<byte> source, Span<byte> dest, out int bytesConsumed, out int bytesWritten, bool isUrl = false)
351351
{
352352

@@ -520,11 +520,10 @@ public unsafe static OperationStatus SafeDecodeFromBase64Scalar(ReadOnlySpan<byt
520520
}
521521
}
522522

523-
524523
// like DecodeFromBase64Scalar, but it will not write past the end of the ouput buffer.
524+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
525525
public unsafe static OperationStatus SafeDecodeFromBase64Scalar(ReadOnlySpan<char> source, Span<byte> dest, out int bytesConsumed, out int bytesWritten, bool isUrl = false)
526526
{
527-
528527
byte[] toBase64 = isUrl != false ? Tables.ToBase64UrlValue : Tables.ToBase64Value;
529528
uint[] d0 = isUrl != false ? Base64Url.d0 : Base64Default.d0;
530529
uint[] d1 = isUrl != false ? Base64Url.d1 : Base64Default.d1;
@@ -758,6 +757,7 @@ public static OperationStatus Base64WithWhiteSpaceToBinaryScalar(ReadOnlySpan<by
758757
return r;
759758
}
760759

760+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
761761
public static OperationStatus Base64WithWhiteSpaceToBinaryScalar(ReadOnlySpan<char> input, Span<byte> output, out int bytesConsumed, out int bytesWritten, bool isUrl = false)
762762
{
763763
int length = input.Length;
@@ -820,8 +820,7 @@ public static OperationStatus Base64WithWhiteSpaceToBinaryScalar(ReadOnlySpan<ch
820820
return r;
821821
}
822822

823-
824-
823+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
825824
public static int Base64LengthFromBinary(int length, bool isUrl = false)
826825
{
827826
if (isUrl)
@@ -832,6 +831,7 @@ public static int Base64LengthFromBinary(int length, bool isUrl = false)
832831
return (length + 2) / 3 * 4;
833832
}
834833

834+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
835835
public unsafe static OperationStatus SafeBase64ToBinaryWithWhiteSpace(ReadOnlySpan<byte> input, Span<byte> output, out int bytesConsumed, out int bytesWritten, bool isUrl = false)
836836
{
837837
// The implementation could be nicer, but we expect that most times, the user
@@ -931,6 +931,7 @@ public unsafe static OperationStatus SafeBase64ToBinaryWithWhiteSpace(ReadOnlySp
931931
return r;
932932
}
933933

934+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
934935
public unsafe static OperationStatus SafeBase64ToBinaryWithWhiteSpace(ReadOnlySpan<char> input, Span<byte> output, out int bytesConsumed, out int bytesWritten, bool isUrl = false)
935936
{
936937
// The implementation could be nicer, but we expect that most times, the user
@@ -1029,11 +1030,7 @@ public unsafe static OperationStatus SafeBase64ToBinaryWithWhiteSpace(ReadOnlySp
10291030
bytesWritten += tailBytesWritten;
10301031
return r;
10311032
}
1032-
1033-
1034-
10351033
}
10361034
}
1037-
10381035
}
10391036

0 commit comments

Comments
 (0)