-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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 TryFindNextStartingPosition #88400
Conversation
Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions |
// final length of the string, so keeping this small helps avoid problematic complexity. | ||
const int MaxPrefixLength = 8; | ||
|
||
// Limit based on what IndexOfAny is able to handle most efficiently. This can be updated in future if/when IndexOfAny improves further. |
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.
Should this point to the private constant in IndexOfAny that defines the value so that it aids in keeping the two values in sync?
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.
Which constant are you referring to?
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.
Sorry, so long since I reviewed this and now I'm trying to page back what I was thinking and can't recall. Should be fine to ignore, I believe I was just trying to suggest to add a pointer here to where that limit is set.
...ies/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexPrefixAnalyzer.cs
Show resolved
Hide resolved
...libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCompiler.cs
Show resolved
Hide resolved
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.
Very minor comments, but this LGTM.
Do we plan to add a benchmark for cases similar to the ones you are adding tests for? Also, if you have, can you share how this impacts the benchmarks we already have? I'm assuming with this we might be faster in some cases while having a slightly bigger memory footprint(for all arrays, strings, etc being allocated)?
9f0a16b
to
e421750
Compare
.../System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexFindOptimizations.cs
Outdated
Show resolved
Hide resolved
…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.
e421750
to
40298bd
Compare
@stephentoub is this PR blocked with something? Looks having a test failure. |
There are some regressions to be investigated and fixed before it can be merged. I will close it for now and revisit it soon. |
Depends on #88394
Fixes #85693
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.