Add fast path for two-character patterns in FuzzyMatchV2

For two ASCII characters, rows 0 and 1 of the score matrix collapse to
scalar running state, so Phase 2 and Phase 3 fuse into one pass with no
score arrays. withPos stores the two rows for the backtrace. Up to 1.4x
on two-char queries, the most common multi-char length.

Verify both fast paths against the general algorithm with exhaustive
(every short string over a class-complete alphabet) and fuzz tests,
runnable via the new make fuzz target.
This commit is contained in:
Junegunn Choi
2026-07-27 21:19:37 +09:00
parent 232722145e
commit f779e6a4df
5 changed files with 410 additions and 3 deletions
+4 -2
View File
@@ -3,8 +3,10 @@ CHANGELOG
0.74.2
------
- Single-character queries are up to 2.4x faster
- This is the most latency-sensitive case; the first keystroke scans the entire list before the result cache can help
- Performance optimizations for short queries
- The most critical case: fzf narrows results as you type, so short queries scan the largest candidate sets and the first keystroke scans the whole input.
- Single-character queries are up to 2.4x faster
- Two-character queries are up to 1.4x faster
- Faster sorting of search results; the default two-criteria ranking skips redundant radix passes
- Fixed nondeterministic match highlight positions
- fzf now detects terminal resize on Windows in `--height` mode (#4790) (@Cyrus580529)