Skip to content

Apply Regex starting loop optimization to non-atomic loops as well - #35936

Merged
stephentoub merged 2 commits into
dotnet:masterfrom
stephentoub:regexatomic
May 9, 2020
Merged

stephentoub merged 2 commits into
dotnet:masterfrom
stephentoub:regexatomic

Conversation

@stephentoub

Copy link
Copy Markdown
Member

@danmosemsft, @eerhardt, @pgovind, this appears sound, but it'd be great if you could double-check me on it.

@stephentoub stephentoub added this to the 5.0 milestone May 7, 2020
@ghost

ghost commented May 7, 2020

Copy link
Copy Markdown

Tagging subscribers to this area: @eerhardt
Notify danmosemsft if you want to be subscribed.

@pgovind

pgovind commented May 8, 2020

Copy link
Copy Markdown

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.

@eerhardt eerhardt left a comment

Copy link
Copy Markdown
Member

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. 😉

@stephentoub stephentoub closed this May 8, 2020
@stephentoub stephentoub reopened this May 8, 2020

@pgovind pgovind left a comment

Copy link
Copy Markdown

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.

@stephentoub
stephentoub merged commit 386ee46 into dotnet:master May 9, 2020
@stephentoub
stephentoub deleted the regexatomic branch May 9, 2020 10:12
@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants