Skip to content

Commit

Permalink
Use ExtractAsciiVector helpers in Base64Url (#107823)
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaZupan authored Sep 24, 2024
1 parent a8d1fc1 commit d830b37
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,11 @@ public unsafe bool TryLoadVector512(ushort* src, ushort* srcStart, int sourceLen
return false;
}

#if NET9_0_OR_GREATER
str = Ascii.ExtractAsciiVector(utf16VectorLower, utf16VectorUpper).AsSByte();
#else
str = Vector512.Narrow(utf16VectorLower, utf16VectorUpper).AsSByte();
#endif
return true;
}

Expand All @@ -699,7 +703,11 @@ public unsafe bool TryLoadAvxVector256(ushort* src, ushort* srcStart, int source
return false;
}

#if NET9_0_OR_GREATER
str = Ascii.ExtractAsciiVector(utf16VectorLower, utf16VectorUpper).AsSByte();
#else
str = Vector256.Narrow(utf16VectorLower, utf16VectorUpper).AsSByte();
#endif
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1677,15 +1677,15 @@ internal static Vector128<byte> ExtractAsciiVector(Vector128<ushort> vectorFirst
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Vector256<byte> ExtractAsciiVector(Vector256<ushort> vectorFirst, Vector256<ushort> vectorSecond)
internal static Vector256<byte> ExtractAsciiVector(Vector256<ushort> vectorFirst, Vector256<ushort> vectorSecond)
{
return Avx2.IsSupported
? PackedSpanHelpers.FixUpPackedVector256Result(Avx2.PackUnsignedSaturate(vectorFirst.AsInt16(), vectorSecond.AsInt16()))
: Vector256.Narrow(vectorFirst, vectorSecond);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Vector512<byte> ExtractAsciiVector(Vector512<ushort> vectorFirst, Vector512<ushort> vectorSecond)
internal static Vector512<byte> ExtractAsciiVector(Vector512<ushort> vectorFirst, Vector512<ushort> vectorSecond)
{
return Avx512BW.IsSupported
? PackedSpanHelpers.FixUpPackedVector512Result(Avx512BW.PackUnsignedSaturate(vectorFirst.AsInt16(), vectorSecond.AsInt16()))
Expand Down

0 comments on commit d830b37

Please sign in to comment.