diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2026-09-16 12:27:54 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-16 12:27:54 +0800 |
| commit | 659aca56f0b2120a586b3f4f8cf2e744993a29f3 (patch) | |
| tree | 740cd3e16bea0ca5df32f533a421567417ed0c29 /runtime/lua/vim/provider/python.lua | |
| parent | c171a697cbee36c4f36535e14f1407909733ca4b (diff) | |
| download | rneovim-659aca56f0b2120a586b3f4f8cf2e744993a29f3.tar.gz rneovim-659aca56f0b2120a586b3f4f8cf2e744993a29f3.tar.bz2 rneovim-659aca56f0b2120a586b3f4f8cf2e744993a29f3.zip | |
vim-patch:9.2.1110: regexp NFA compilation reallocates scratch buffers each time (#41936)
Problem: Every NFA regexp compilation allocates and frees two temporary
scratch buffers, the postfix list and the fragment stack, even
though the NFA states themselves are already allocated in a
single block; this repeats for every pattern, e.g. the hundreds
of autocmd patterns and syntax items loaded when opening a file.
Solution: Keep the postfix list and the fragment stack allocated between
compilations, growing them only when a larger one is needed, and
free them once in free_regexp_stuff().
The backtracking engine already uses this approach: it keeps its "regstack"
and "backpos" scratch buffers across invocations, allocating them only when
not present, and frees them in free_regexp_stuff(). Apply the same reuse to
the NFA "post_start" postfix list and the post2nfa() fragment stack by making
them grow-only statics. Only the scratch memory management changes; the
compiled program and matching are unaffected.
Measured with callgrind (instructions retired), against baseline:
- opening a single C file: ~3%
- opening a Vim script file: ~2.5%
- cold start opening a file (full runtime): -3%
- repeated ":runtime! syntax/c.vim" (x40): -2.5%
- opening 51 real source files in a session: -2%
closes: vim/vim#21307
https://github.com/vim/vim/commit/09c21a413f7a865a44829407f01dfa92817046ed
Co-authored-by: Julien Voisin <julien.voisin@dustri.org>
Diffstat (limited to 'runtime/lua/vim/provider/python.lua')
0 files changed, 0 insertions, 0 deletions