Refactor the UTF-8 hot paths in src/mbyte.c so codepoint decoding and byte-length validation are done once and reused by callers. This removes repeated utf_ptr2char()/utf_ptr2len() work in utf_ptr2cells(), utf_ptr2cells_len(), utfc_ptr2char(), utfc_ptr2char_len(), and the shared length helpers used by redraw and display-width code paths.
Benchmark: 8.31% faster in a redraw-heavy UTF-8 editing scenario with long lines full of Japanese text, emoji, combining characters, and full-width glyphs. The measured case used 4000 long UTF-8 lines with list, linebreak, number, and cursorline enabled, then repeatedly performed cursor moves, horizontal scrolling, virtcol('$'), and redraw! calls.
https://github.com/vim/vim/pull/19649
(1 file)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
@mattn pushed 1 commit.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Many call sites use multiple utf_ptr2xxx() helpers on the same bytes, for example to get both the decoded character and its length. That means we end up walking the same UTF-8 sequence more than once and doing redundant work in hot paths.
If we provide a way to get both values in a single pass, ASCII might become a little slower in some places due to the extra plumbing, but multibyte text should consistently benefit from it.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()