Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
Keegan Caruso committed Feb 27, 2024
1 parent bd53dff commit ecfdd53
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</ItemGroup>-->

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.5" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
Expand Down
8 changes: 4 additions & 4 deletions src/Microsoft.IdentityModel.Tokens/Base64UrlEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ internal static unsafe byte[] UnsafeDecode(ReadOnlySpan<char> strSpan)
#if NET6_0_OR_GREATER
// If the incoming chars don't contain any of the base64url characters that need to be replaced,
// and if the incoming chars are of the exact right length, then we'll be able to just pass the
// incoming chars directly to Convert.TryFromBase64Chars. Otherwise, rent an array, copy all the
// incoming chars directly to DecodeFromUtf8InPlace. Otherwise, rent an array, copy all the
// data into it, and do whatever fixups are necessary on that copy, then pass that copy into
// Convert.TryFromBase64Chars.
// DecodeFromUtf8InPlace.

const int StackAllocThreshold = 512;
char[] arrayPoolChars = null;
Expand Down Expand Up @@ -237,8 +237,8 @@ internal static unsafe byte[] UnsafeDecode(ReadOnlySpan<char> strSpan)
arrayPoolBytes = ArrayPool<byte>.Shared.Rent(decodedLength);

int length = Encoding.UTF8.GetBytes(source, bytesSpan);
var utf8Span = bytesSpan.Slice(0, length);
var status = System.Buffers.Text.Base64.DecodeFromUtf8InPlace(utf8Span, out int bytesWritten);
Span<byte> utf8Span = bytesSpan.Slice(0, length);
OperationStatus status = System.Buffers.Text.Base64.DecodeFromUtf8InPlace(utf8Span, out int bytesWritten);
Debug.Assert(status == OperationStatus.Done, "Expected DecodeFromUtf8 to be successful");

byte[] result = bytesSpan.Slice(0, bytesWritten).ToArray();
Expand Down

0 comments on commit ecfdd53

Please sign in to comment.