m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-18 00:03:39 -05:00

Improve search performance by limiting the search scope

Find the last occurrence of the last character in the pattern and
perform the search algorithm only up to that point.

The effectiveness of this mechanism depends a lot on the shape of the
input and the pattern.
This commit is contained in:
Junegunn Choi
2024-04-14 07:52:42 +09:00
parent a5447b8b75
commit e86b81bbf5
4 changed files with 99 additions and 34 deletions

View File

@@ -173,6 +173,12 @@ func (r *Reader) feed(src io.Reader) {
}
} else {
// Could not find the delimiter in the buffer
// NOTE: We can further optimize this by keeping track of the cursor
// position in the slab so that a straddling item that doesn't go
// beyond the boundary of a slab doesn't need to be copied to
// another buffer. However, the performance gain is negligible in
// practice (< 0.1%) and is not
// worth the added complexity.
leftover = append(leftover, buf...)
break
}