Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
using System.Runtime.Intrinsics.Wasm;
using System.Runtime.Intrinsics.X86;

Expand Down Expand Up @@ -134,12 +135,6 @@ ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(values)),
return new Any5SearchValues<char, short>(shortValues);
}

if (maxInclusive < 256)
{
// This will also match ASCII values when IndexOfAnyAsciiSearcher is not supported
return new Latin1CharSearchValues(values);
}

scoped ReadOnlySpan<char> probabilisticValues = values;

if (Vector128.IsHardwareAccelerated && values.Length < 8)
Expand All @@ -162,6 +157,13 @@ ref Unsafe.As<char, short>(ref MemoryMarshal.GetReference(values)),
: new ProbabilisticWithAsciiCharSearchValues<IndexOfAnyAsciiSearcher.Default>(probabilisticValues);
}

// We prefer using the ProbabilisticMap over Latin1CharSearchValues if the former is vectorized.
if (!(Sse41.IsSupported || AdvSimd.Arm64.IsSupported) && maxInclusive < 256)
{
// This will also match ASCII values when IndexOfAnyAsciiSearcher is not supported.
return new Latin1CharSearchValues(values);
}

return new ProbabilisticCharSearchValues(probabilisticValues);
}

Expand Down