Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Conversation

@MihaZupan
Copy link
Member

@MihaZupanMihaZupan commentedFeb 25, 2024
edited
Loading

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.

publicclassIgnoreCaseToOrdinal{privatestaticreadonlySearchValues<string>s_values=SearchValues.Create(["ab","c!"],StringComparison.OrdinalIgnoreCase);privatereadonlystring_text=new('\n',1000);[Benchmark]publicintIndexOfAny()=>_text.AsSpan().IndexOfAny(s_values);}
MethodToolchainMeanErrorRatio
IndexOfAny\main\corerun.exe82.42 ns0.596 ns1.00
IndexOfAny\pr\corerun.exe67.83 ns0.369 ns0.82

danmoseley reacted with heart emojiPaulusParssinen reacted with rocket emoji
@MihaZupanMihaZupan added this to the9.0.0 milestoneFeb 25, 2024
@MihaZupanMihaZupan self-assigned thisFeb 25, 2024
@ghost
Copy link

Tagging subscribers to this area: @dotnet/area-system-buffers
See info inarea-owners.md if you want to be subscribed.

Issue Details

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 both the prefix search loop and the verification steps are a bit simpler due to not needing to deal with casing.

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);}
MethodToolchainMeanErrorRatio
IndexOfAny\main\corerun.exe82.42 ns0.596 ns1.00
IndexOfAny\pr\corerun.exe67.83 ns0.369 ns0.82
Author:MihaZupan
Assignees:MihaZupan
Labels:

area-System.Buffers

Milestone:9.0.0

@MihaZupanMihaZupanforce-pushed thesearchvalues-string-shortCasePermutations branch from54e8e3d toac5966cCompareMarch 2, 2024 03:13
@MihaZupanMihaZupan merged commit8aff565 intodotnet:mainMar 2, 2024
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsApr 2, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@stephentoubstephentoubstephentoub approved these changes

Assignees

@MihaZupanMihaZupan

Projects

None yet

Milestone

9.0.0

Development

Successfully merging this pull request may close these issues.

2 participants

@MihaZupan@stephentoub

[8]ページ先頭

©2009-2025 Movatter.jp