Skip to content
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

Regex compiler/ source generator can use {Last}IndexOf for strings in greedy char loop #62670

Closed
stephentoub opened this issue Dec 11, 2021 · 2 comments · Fixed by #63428
Closed
Assignees
Milestone

Comments

@stephentoub
Copy link
Member

stephentoub commented Dec 11, 2021

In greedy char loops, if the loop is followed by a known literal, when backtracking we LastIndexOf to find the next possible place to try to continue the match, rather than just backing up one char at a time. Today we only do this based on a subsequent char literal, but we can extend it to look for a subsequent multi as well. We can also build a set of all possible subsequent chars and do a LastIndexOfAny, e.g. for ".*[abc]".

@stephentoub stephentoub added the tenet-performance Performance related issue label Dec 11, 2021
@stephentoub stephentoub added this to the 7.0.0 milestone Dec 11, 2021
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Dec 11, 2021
@ghost
Copy link

ghost commented Dec 11, 2021

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

Issue Details

In greedy char loops, if the loop is followed by a known literal, when backtracking we LastIndexOf to find the next possible place to try to continue the match, rather than just backing up one char at a time. Today we only do this based on a subsequent char literal, but we can extend it to look for a subsequent multi as well. (We could even build a set of all possible subsequent chars and do a LastIndexOfAny, though the benefits of that appear to be less common.)

Author: stephentoub
Assignees: -
Labels:

area-System.Text.RegularExpressions, tenet-performance, untriaged

Milestone: 7.0.0

@stephentoub stephentoub changed the title Regex source generator can use {Last}IndexOf for strings in greedy char loop Regex compiler/ source generator can use {Last}IndexOf for strings in greedy char loop Dec 13, 2021
@stephentoub stephentoub self-assigned this Jan 3, 2022
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jan 6, 2022
@stephentoub stephentoub removed the untriaged New issue has not been triaged by the area owner label Jan 6, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jan 15, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Feb 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant