Skip to content

Use char helpers for ASCII portion of Regex character class matching#77604

Merged
stephentoub merged 1 commit intodotnet:mainfrom
stephentoub:regexascii
Oct 28, 2022
Merged

Use char helpers for ASCII portion of Regex character class matching#77604
stephentoub merged 1 commit intodotnet:mainfrom
stephentoub:regexascii

Conversation

@stephentoub
Copy link
Member

If the entire character class is ASCII, we already use char.IsXx helpers when they're equivalent, e.g. [A-Z] will result in using char.IsAsciiLetterUpper. But if the character class contains any non-ASCII, we always use a lookup table for the ASCII portion of the comparison. This PR allows us to similarly use those IsAsciiXx helpers for the ASCII portion. This primarily about making the generated code cleaner, but it can also save a few instructions.

If the entire character class is ASCII, we already use char.IsXx helpers when they're equivalent, e.g. [A-Z] will result in using char.IsAsciiLetterUpper.  But if the character class contains any non-ASCII, we always use a lookup table for the ASCII portion of the comparison.  This PR allows us to similarly use those IsAsciiXx helpers for the ASCII portion.
@ghost
Copy link

ghost commented Oct 28, 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

If the entire character class is ASCII, we already use char.IsXx helpers when they're equivalent, e.g. [A-Z] will result in using char.IsAsciiLetterUpper. But if the character class contains any non-ASCII, we always use a lookup table for the ASCII portion of the comparison. This PR allows us to similarly use those IsAsciiXx helpers for the ASCII portion. This primarily about making the generated code cleaner, but it can also save a few instructions.

Author: stephentoub
Assignees: -
Labels:

area-System.Text.RegularExpressions

Milestone: 8.0.0

@stephentoub stephentoub merged commit 659fb5b into dotnet:main Oct 28, 2022
@stephentoub stephentoub deleted the regexascii branch October 28, 2022 23:30
@ghost ghost locked as resolved and limited conversation to collaborators Nov 28, 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.

3 participants