-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Apply Regex starting loop optimization to non-atomic loops as well #35936
Conversation
Tagging subscribers to this area: @eerhardt |
I missed this PR somehow. I'll go over the logic and comment/approve tomorrow |
The node.N > 0 restriction isn't necessary, and prevents this optimization from being used with * loops. Worst case, the loop doesn't match anything, and we pay to overwrite the starting position with itself. Best case, we eliminate a ton of cost.
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.
I can't think of a reason why this would break. If you are convinced it is correct, I think that's good enough for me. 😉
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexNode.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.
Alright, this looks good to me. I spent some time going over the parsing logic , ran some patterns locally and am reasonably convinced that this is a safe change.
@danmosemsft, @eerhardt, @pgovind, this appears sound, but it'd be great if you could double-check me on it.