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

Extend Regex alternation source generator optimization to small sets #62438

Closed
stephentoub opened this issue Dec 6, 2021 · 1 comment · Fixed by #63756
Closed

Extend Regex alternation source generator optimization to small sets #62438

stephentoub opened this issue Dec 6, 2021 · 1 comment · Fixed by #63756
Assignees
Milestone

Comments

@stephentoub
Copy link
Member

In the Regex source generator, we special-case alternations where every branch begins with a different char, preferring to generate a switch statement, e.g. "abc|def" yields a switch statement with a case for 'a' and a case for 'd', as the implementation sees that all branches begin with a different character and thus there's no need to fall through from one case to the next, nor backtrack. However, we don't currently extend this to small sets, e.g. "[Aa]bc|[Dd]ef" could similarly benefit from a switch. This will be even more impactful now that IgnoreCase produces sets for all case-equivalent variations of a letter, e.g. "abc|def" under IgnoreCase producing the equivalent of "[Aa][Bb][Cc]|[Dd][Ee][Ff]".

@stephentoub stephentoub added this to the 7.0.0 milestone Dec 6, 2021
@ghost
Copy link

ghost commented Dec 6, 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 the Regex source generator, we special-case alternations where every branch begins with a different char, preferring to generate a switch statement, e.g. "abc|def" yields a switch statement with a case for 'a' and a case for 'd', as the implementation sees that all branches begin with a different character and thus there's no need to fall through from one case to the next, nor backtrack. However, we don't currently extend this to small sets, e.g. "[Aa]bc|[Dd]ef" could similarly benefit from a switch. This will be even more impactful now that IgnoreCase produces sets for all case-equivalent variations of a letter, e.g. "abc|def" under IgnoreCase producing the equivalent of "[Aa][Bb][Cc]|[Dd][Ee][Ff]".

Author: stephentoub
Assignees: -
Labels:

area-System.Text.RegularExpressions, tenet-performance

Milestone: 7.0.0

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Dec 6, 2021
@joperezr joperezr added help wanted [up-for-grabs] Good issue for external contributors and removed untriaged New issue has not been triaged by the area owner help wanted [up-for-grabs] Good issue for external contributors labels Dec 6, 2021
@stephentoub stephentoub self-assigned this Jan 13, 2022
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jan 13, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jan 19, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Feb 18, 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.

2 participants