You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For a number of values <= 5, string.IndexOfAny just delegates to MemoryExtensions.IndexOfAny. But for values length > 5, it implements a "probabilistic map" (basically a Bloom filter) that it uses when walking each element of the input to determine whether it's likely in the set, and then does the actual comparison against the set only for the likely ones. In contrast, for values length > 5, MemoryExtensions.IndexOfAny walks each character in the input, and for each walks each of the values to see if they match.
There's little reason these should be different. We should decide on and pick the better strategy (or an even better one if such a thing exists), use it in MemoryExtensions.IndexOfAny, and then have the string.IndexOfAny just unconditionally delegate to MemoryExtensions.
Tagging subscribers to this area: @dotnet/area-system-runtime
See info in area-owners.md if you want to be subscribed.
Issue Details
For a number of values <= 5, string.IndexOfAny just delegates to MemoryExtensions.IndexOfAny. But for values length > 5, it implements a "probabilistic map" (basically a Bloom filter) that it uses when walking each element of the input to determine whether it's likely in the set, and then does the actual comparison against the set only for the likely ones. In contrast, for values length > 5, MemoryExtensions.IndexOfAny walks each character in the input, and for each walks each of the values to see if they match.
There's little reason these should be different. We should decide on and pick the better strategy (or an even better one if such a thing exists), use it in MemoryExtensions.IndexOfAny, and then have the string.IndexOfAny just unconditionally delegate to MemoryExtensions.
For a number of values <= 5, string.IndexOfAny just delegates to MemoryExtensions.IndexOfAny. But for values length > 5, it implements a "probabilistic map" (basically a Bloom filter) that it uses when walking each element of the input to determine whether it's likely in the set, and then does the actual comparison against the set only for the likely ones. In contrast, for values length > 5, MemoryExtensions.IndexOfAny walks each character in the input, and for each walks each of the values to see if they match.
There's little reason these should be different. We should decide on and pick the better strategy (or an even better one if such a thing exists), use it in MemoryExtensions.IndexOfAny, and then have the string.IndexOfAny just unconditionally delegate to MemoryExtensions.
cc: @GrabYourPitchforks
The text was updated successfully, but these errors were encountered: