Skip to content

Fix matching for non-ASCII-equivalent ASCII chars - #903

Open
natecook1000 wants to merge 1 commit into
swiftlang:mainfrom
natecook1000:fix/non-ascii-match
Open

natecook1000 wants to merge 1 commit into
swiftlang:mainfrom
natecook1000:fix/non-ascii-match

Conversation

@natecook1000

Copy link
Copy Markdown
Member

Three non-ASCII scalars have canonical equivalence to ASCII ones:

U+037E GREEK QUESTION MARK  ==  ";"
U+212A KELVIN SIGN          ==  "K"
U+1FEF GREEK VARIA          ==  "`"

For these ASCII characters, we can't just rely on byte-by-byte matching. This change detects those characters in runs that can otherwise be matched at the byte level and inserts matchScalarPair instructions as needed for correct matching. Skipping ASCII matching for these characters incurs some additional runtime cost, so this change includes a new instruction that can match either of two scalars, combined in a single payload.

When matching with Unicode scalar semantics, this adjustment isn't needed, since canonical equivalence doesn't play a role in matching.

Three non-ASCII scalars have canonical equivalence to ASCII ones:

    U+037E GREEK QUESTION MARK  ==  ";"
    U+212A KELVIN SIGN          ==  "K"
    U+1FEF GREEK VARIA          ==  "`"

For these ASCII characters, we can't just rely on byte-by-byte
matching. This change detects those characters in runs that can
otherwise be matched at the byte level and inserts `matchScalarPair`
instructions as needed for correct matching.

When matching with Unicode scalar semantics, this adjustment isn't
needed, since canonical equivalence doesn't play a role in matching.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant