mirror of
https://github.com/dotnet/skills.git
synced 2026-09-20 09:49:54 +08:00
e23c4247ce
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
16 lines
450 B
C#
16 lines
450 B
C#
using System.Runtime.Intrinsics;
|
|
|
|
public static class AsciiLetters
|
|
{
|
|
public static bool StartsWithAsciiLetter(ReadOnlySpan<char> text)
|
|
{
|
|
if (!Vector128.IsHardwareAccelerated || text.Length < Vector128<char>.Count)
|
|
{
|
|
return text.Length != 0 && char.IsAsciiLetter(text[0]);
|
|
}
|
|
|
|
Vector128<char> chars = Vector128.Create(text);
|
|
return chars[0] is >= 'A' and <= 'Z' or >= 'a' and <= 'z';
|
|
}
|
|
}
|