Commit Graph

14 Commits (master)

Author SHA1 Message Date
Junegunn Choi e8405f40fe
Refactor the code so that fzf can be used as a library (#3769) 2 weeks ago
Christian Muehlhaeuser 3b9dbd4146 Code cleanup: remove unnecessary string conversions (#1642) 5 years ago
Ryan Boehning 21b94d2de5
Make fzf pass go vet
Add String() methods to types, so they can be printed with %s. Change
some %s format specifiers to %v, when the default string representation
is good enough. In Go 1.10, `go test` triggers a parallel `go vet`. So
this also makes fzf pass `go test`.

Close #1236
Close #1219
6 years ago
Junegunn Choi c9f16b6430
Avoid unconditionally storsing input as runes
When --with-nth is used, fzf used to preprocess each line and store the
result as rune array, which was wasteful if the line only contains ascii
characters.
7 years ago
Junegunn Choi 2e3dc75425
Fix inconsistent tiebreak scores when --nth is used
Make sure to consistently calculate tiebreak scores based on the
original line.

This change may not be preferable if you filter aligned tabular input on
a subset of columns using --nth. However, if we calculate length
tiebreak only on the matched components instead of the entire line, the
result can be very confusing when multiple --nth components are
specified, so let's keep it simple and consistent.

Close #926
7 years ago
Junegunn Choi 1d4057c209
[perf] Avoid allocating rune array for ascii string
In the best case (all ascii), this reduces the memory footprint by 60%
and the response time by 15% to 20%. In the worst case (every line has
non-ascii characters), 3 to 4% overhead is observed.
8 years ago
Junegunn Choi 92a75c9563 Use trimmed length when --nth is used with --tiebreak=length
This change improves sort ordering for aligned tabular input.
Given the following input:

    apple   juice   100
    apple   pie     200

fzf --nth=2 will now prefer the one with pie. Before this change fzf
compared "juice   " and "pie     ", both of which have the same length.
9 years ago
Junegunn Choi d0f2c00f9f Fix --with-nth performance; use simpler regular expression
Related #317
9 years ago
Junegunn Choi 766427de0c Fix --with-nth performance; avoid regex if possible
Close #317
9 years ago
Junegunn Choi 0ea66329b8 Performance tuning - eager rune array conversion
> wc -l /tmp/list2
     2594098 /tmp/list2

    > time cat /tmp/list2 | fzf-0.10.1-darwin_amd64 -fqwerty > /dev/null

    real    0m5.418s
    user    0m10.990s
    sys     0m1.302s

    > time cat /tmp/list2 | fzf-head -fqwerty > /dev/null

    real    0m4.862s
    user    0m6.619s
    sys     0m0.982s
9 years ago
Junegunn Choi 2fe1e28220 Improvements in performance and memory usage
I profiled fzf and it turned out that it was spending significant amount
of time repeatedly converting character arrays into Unicode codepoints.
This commit greatly improves search performance after the initial scan
by memoizing the converted results.

This commit also addresses the problem of unbounded memory usage of fzf.
fzf is a short-lived process that usually processes small input, so it
was implemented to cache the intermediate results very aggressively with
no notion of cache expiration/eviction. I still think a proper
implementation of caching scheme is definitely an overkill. Instead this
commit introduces limits to the maximum size (or minimum selectivity) of
the intermediate results that can be cached.
9 years ago
Junegunn Choi 7a2bc2cada Lint 9 years ago
Junegunn Choi ee2ee02599 Fix index out of bounds error during Transform 10 years ago
Junegunn Choi f3177305d5 Rewrite fzf in Go 10 years ago