- Notifications
You must be signed in to change notification settings - Fork5.2k
Expand small value sets to all case permutations in SearchValues<string>#98902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Expand small value sets to all case permutations in SearchValues<string>#98902
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ghost commentedFeb 25, 2024
Tagging subscribers to this area: @dotnet/area-system-buffers Issue DetailsImplements#98791 (comment) If we have a set of values like This optimization is a bit niche (unlikely to be applicable often), but it's really cheap to check whether it could apply, and can help cases with many non-letter characters in their prefixes. publicclassIgnoreCaseToOrdinal{privatestaticreadonlySearchValues<string>s_values=SearchValues.Create(["ab","c!"],StringComparison.OrdinalIgnoreCase);privatereadonlystring_text=new('\n',1000);[Benchmark]publicintIndexOfAny()=>_text.AsSpan().IndexOfAny(s_values);}
|
src/libraries/System.Private.CoreLib/src/System/SearchValues/Strings/StringSearchValues.csShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/System.Private.CoreLib/src/System/SearchValues/Strings/StringSearchValues.csShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/System.Private.CoreLib/src/System/SearchValues/Strings/StringSearchValues.csShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/System.Private.CoreLib/src/System/SearchValues/Strings/StringSearchValues.csShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
54e8e3d toac5966cCompare
Uh oh!
There was an error while loading.Please reload this page.
Implements#98791 (comment)
If we have a set of values like
["ab", "c!"], we can expand it to["ab", "Ab" "aB", "AB", "c!", "C!"]and switch to case-sensitive searching.As long as we're making use of buckets that would otherwise have been empty, this is going to be an improvement as the prefix search loop is a bit simpler due to not needing to deal with casing. In the below benchmark, it means eliminatingthis step from the loop.
This optimization is a bit niche (unlikely to be applicable often), but it's really cheap to check whether it could apply, and can help cases with many non-letter characters in their prefixes.