-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable Regex to use SearchValues<string> in compiled / source generator for IgnoreCase multi-strings #98791
Enable Regex to use SearchValues<string> in compiled / source generator for IgnoreCase multi-strings #98791
Conversation
…or TryFindNextStartingPosition The analyzer determines a set of prefixes that can start any match, and then uses SearchValues with IndexOfAny to find the next one from that set. It's currently only enabled for case-insensitive; we need to do some more perf validation before enabling for case-sensitive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
src/libraries/System.Text.RegularExpressions/gen/RegexGenerator.Emitter.cs
Outdated
Show resolved
Hide resolved
...ies/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexPrefixAnalyzer.cs
Outdated
Show resolved
Hide resolved
// Arbitrary string length limit (with some wiggle room) to avoid creating strings that are longer than is useful and consuming too much memory. | ||
const int MaxPrefixLength = 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
longer than is useful and consuming too much memory
This is mainly about not spending too many resources on the analysis part, not about the cost of the potential SearchValues
itself, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, "the longer than is useful" part was about SearchValues itself. Is that not the case?
...ies/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexPrefixAnalyzer.cs
Show resolved
Hide resolved
...ies/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexPrefixAnalyzer.cs
Show resolved
Hide resolved
src/libraries/System.Text.RegularExpressions/tests/UnitTests/RegexPrefixAnalyzerTests.cs
Show resolved
Hide resolved
A lot of work to get to this point! I guess I should remeasure the rust benchmarks with all the alternations. |
Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions Issue DetailsThe analyzer determines a set of prefixes that can start any match, and then uses
Contributes to #85693
|
The analyzer determines a set of prefixes that can start any match, and then uses
SearchValues<string>
with IndexOfAny to find the next one from that set. It's currently only enabled for case-insensitive; we need to do some more perf validation before enabling for case-sensitive.Contributes to #85693