Skip to content

Refactor(Hangul): Simplify LV/LVT classification and improve performance#34

Open
rmaksim wants to merge 1 commit into
orling:masterfrom
rmaksim:master
Open

Refactor(Hangul): Simplify LV/LVT classification and improve performance#34
rmaksim wants to merge 1 commit into
orling:masterfrom
rmaksim:master

Conversation

@rmaksim

@rmaksim rmaksim commented Nov 10, 2025

Copy link
Copy Markdown

Replaced lengthy 'if' chains and explicit range checks for Hangul (Korean) syllables with a single mathematical check based on the Unicode standard.

What was simplified:

  • Eliminated two large, complex conditional blocks (if statements) that manually enumerated dozens of code points and ranges for LV and LVT syllable types.
  • Improved code readability by replacing imperative, error-prone enumeration with a single, declarative formula: (code - 0xAC00) % 28.

What was optimized:

  • Performance (CPU): Significantly reduced execution time by replacing numerous sequential OR (||) and range checks with a single range check and one modulo operation (% 28). This is faster for the JavaScript engine.
  • Code Size: Dramatically reduced the file size and complexity by removing the bulky code dedicated to manually implementing Unicode rules.

Replaced lengthy 'if' chains and explicit range checks for Hangul (Korean) syllables with a single mathematical check based on the Unicode standard.

What was simplified:
* Eliminated two large, complex conditional blocks (`if` statements) that manually enumerated dozens of code points and ranges for LV and LVT syllable types.
* Improved code readability by replacing imperative, error-prone enumeration with a single, declarative formula: `(code - 0xAC00) % 28`.

What was optimized:
* **Performance (CPU):** Significantly reduced execution time by replacing numerous sequential OR (`||`) and range checks with a single range check and one modulo operation (`% 28`). This is faster for the JavaScript engine.
* **Code Size:** Dramatically reduced the file size and complexity by removing the bulky code dedicated to manually implementing Unicode rules.
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