UnicodeUtil: skip Hangul decompose/compose when no Hangul syllables present#390
Open
Copilot wants to merge 3 commits into
Open
UnicodeUtil: skip Hangul decompose/compose when no Hangul syllables present#390Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
…se/compose calls Agent-Logs-Url: https://github.com/elharo/xom/sessions/0936fd40-179a-4ab0-a19a-ff83ce25893a Co-authored-by: elharo <1005544+elharo@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Optimize normalize() to conditionally call Hangul methods
UnicodeUtil: skip Hangul decompose/compose when no Hangul syllables present
Apr 1, 2026
elharo
reviewed
Apr 1, 2026
| if (c > 255) { | ||
| needsNormalizing = true; | ||
| break; | ||
| if (c >= FIRST_HANGUL_SYLLABLE && c <= LAST_HANGUL_SYLLABLE) { |
Owner
There was a problem hiding this comment.
does it make sense to instead scan forward from i at this point looking specifically for hangul characters since we already know normalizing is needed, avoiding the c > 255 and needsNormalizing checks?
Contributor
Author
There was a problem hiding this comment.
Done in 5e9fe27. The first loop now breaks immediately on finding any c > 255 (setting needsNormalizing). If that character is already Hangul we're done; otherwise a second, focused loop scans from position i+1 checking only the Hangul range, avoiding the redundant c > 255 test.
…er suggestion Agent-Logs-Url: https://github.com/elharo/xom/sessions/da3d8e96-a25c-42c6-9863-6a4fadd4ec66 Co-authored-by: elharo <1005544+elharo@users.noreply.github.com>
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.
normalize()unconditionally calleddecomposeHangul()andcomposeHangul()— both O(n) passes — even for strings with no Hangul content (0xAC00–0xD7A3). This penalizes all non-ASCII normalization (Greek, Arabic, CJK, etc.).Changes
hasHangul = trueand breaks early on first match; otherwise continues scanning so a Hangul character appearing later in the string isn't missed.decomposeHangul()andcomposeHangul()are now gated onhasHangul.