Repository navigation
[WTF] toLowerCase should not call ICU for ASCII and caseless characters - #79713
Open
sosukesuzuki wants to merge 1 commit into
Conversation
…ters https://bugs.webkit.org/show_bug.cgi?id=330241 Reviewed by NOBODY (OOPS!). Lowercasing a 16-bit string calls ICU when the string has any non-ASCII character, even when that character never changes, as in Japanese, Chinese and Korean text or in English text with a curly quote. This patch skips ICU when every character is ASCII or in a small table of ranges with Changes_When_Lowercased=No [1]. The string itself is returned when it has no ASCII uppercase letter. The table does not have to be complete, since any other character still goes to ICU. Baseline Patched string-to-lower-case-caseless 89.7924+-6.0371 ^ 51.8034+-4.8645 ^ definitely 1.7333x faster [1]: https://www.unicode.org/Public/UCD/latest/ucd/DerivedCoreProperties.txt Tests: JSTests/microbenchmarks/string-to-lower-case-caseless.js JSTests/stress/to-lower-case-caseless.js * JSTests/microbenchmarks/string-to-lower-case-caseless.js: Added. (test): * JSTests/stress/to-lower-case-caseless.js: Added. (shouldBe): (toLowerCaseWithICU): * Source/WTF/wtf/text/StringImpl.cpp: (WTF::containsOnlyASCIIOrCaseless): (WTF::StringImpl::convertToLowercaseWithoutLocaleStartingAtFailingIndex16Bit):
Collaborator
|
EWS run on current version of this PR (hash 7887d7b) Details |
This was referenced Nov 12, 2026
| { 0xAC00, 0xD7A3 }, // Hangul Syllables | ||
| { 0xE000, 0xFAFF }, // Private Use Area and CJK Compatibility Ideographs | ||
| { 0xFF01, 0xFF20 }, // Fullwidth ASCII punctuation and digits | ||
| } }; |
Member
There was a problem hiding this comment.
Can you add a code testing this ranges are correct with ICU when ASSERT_ENABLED is true? We would like to guard the logic against future Unicode changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
7887d7b
7887d7b