diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2026-04-13 07:30:32 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-13 07:30:32 +0800 |
| commit | 34288b3eecac12ddf1b69c4a11b50c993466fb31 (patch) | |
| tree | ed57861398ad722fc61d35be9b46c1d75f1ac8bc /scripts/lintcommit.lua | |
| parent | b081cc3aeb054ef96d7be9f4c2fd13145791b451 (diff) | |
| download | rneovim-34288b3eecac12ddf1b69c4a11b50c993466fb31.tar.gz rneovim-34288b3eecac12ddf1b69c4a11b50c993466fb31.tar.bz2 rneovim-34288b3eecac12ddf1b69c4a11b50c993466fb31.zip | |
vim-patch:9.2.0339: regexp: nfa_regmatch() allocates and frees too often (#38996)
Problem: nfa_regmatch() allocates and frees two list buffers on every
call, causing unnecessary memory allocation overhead for
frequently used patterns.
Solution: Cache the list buffers in the regprog struct and reuse them
on subsequent top-level calls. Recursive calls still allocate
their own buffers. Free cached buffers in nfa_regfree()
(Yasuhiro Matsumoto).
Benchmark: 10K lines, `:%s` x50 iterations
| Pattern | Before | After | Improvement |
|---|---|---|---|
| `\<\(\w\+\%(ing\|tion\|ed\|ly\)\|\w\{3,}\)\>` (many matches) | 4.384s | 4.299s | -2% |
| `\(foo\|bar\|baz\)\{3,}\(qux\|quux\|corge\)\{2,}...` (no match, high nstate) | 16.927s | 3.015s | -82% |
closes: vim/vim#19956
https://github.com/vim/vim/commit/105d65e29b636981b2a92cd0205b19f85951d770
Co-authored-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Diffstat (limited to 'scripts/lintcommit.lua')
0 files changed, 0 insertions, 0 deletions