Skip to content

Extend case optimization in MatchCharacterClass to all chars that differ by one bit #63275

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

Merged
merged 1 commit into from
Jan 4, 2022

Conversation

stephentoub
Copy link
Member

In RegexCompiler / source generator, we optimize matching a set like [Aa] to just do (ch | 0x20) == 'a'. But we can trivially extend this to any pair of characters that differ by only a single bit and not just to casing.

@ghost
Copy link

ghost commented Jan 3, 2022

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 RegexCompiler / source generator, we optimize matching a set like [Aa] to just do (ch | 0x20) == 'a'. But we can trivially extend this to any pair of characters that differ by only a single bit and not just to casing.

Author: stephentoub
Assignees: -
Labels:

area-System.Text.RegularExpressions, tenet-performance

Milestone: -

Copy link
Member

@joperezr joperezr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Can we add a couple of tests that use this which are not just casing?

@stephentoub
Copy link
Member Author

Can we add a couple of tests that use this which are not just casing?

We have some (I know because I had a bug that caused a variety of tests to fail), but I can add some explicitly.

@stephentoub stephentoub merged commit 8359690 into dotnet:main Jan 4, 2022
@stephentoub stephentoub deleted the regexmatchbit branch January 4, 2022 01:38
@ghost ghost locked as resolved and limited conversation to collaborators Feb 3, 2022
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.

2 participants