Files
neovim/src
zeertzjq 34288b3eec 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

105d65e29b

Co-authored-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
2026-04-13 07:30:32 +08:00
..
2023-11-05 20:19:06 +01:00
2025-08-02 15:58:11 -07:00
2025-12-08 01:43:02 -05:00