diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2026-09-03 11:06:35 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-03 11:06:35 +0800 |
| commit | aff123a5d474d3c1ebd0eef494843535071033c6 (patch) | |
| tree | 5b3fa562298dcff5354f12a79559abedbf4eddc7 /runtime/lua/vim/_stringbuffer.lua | |
| parent | 89837bdd72a89cab69d3117021d087fce09c118d (diff) | |
| download | rneovim-aff123a5d474d3c1ebd0eef494843535071033c6.tar.gz rneovim-aff123a5d474d3c1ebd0eef494843535071033c6.tar.bz2 rneovim-aff123a5d474d3c1ebd0eef494843535071033c6.zip | |
vim-patch:9.2.1034: NFA regexp matching is slow for ASCII text (#41642)
Problem: NFA regexp matching is slower than necessary for ASCII text
because two indirect function calls are made for every
character.
Solution: Add an inline fast path for an ASCII byte that is not followed
by a composing character (Julien Voisin).
The main loop of nfa_regmatch() fetched the current character and its
byte length with two calls through the mb_ptr2char and mb_ptr2len
function pointers on every character. These pointers cannot be inlined,
yet for ASCII text, which is the common case, both merely return the byte
and a length of one.
Handle that case inline. NUL is checked first so that reading the next
byte cannot go past the end of the line, and the "next byte is ASCII"
condition matches the check in utfc_ptr2len(), so a base character
followed by a composing character still falls through to the original
calls.
A "perf stat -e instructions" on a full scroll of a 60000 line C file with
syntax highlighting enabled shows an instructions count reduction of 4%.
closes: vim/vim#21179
https://github.com/vim/vim/commit/58390ca285d8dae3f15134396894e0343fa4399e
Co-authored-by: Julien Voisin <julien.voisin@dustri.org>
Diffstat (limited to 'runtime/lua/vim/_stringbuffer.lua')
0 files changed, 0 insertions, 0 deletions