Commit Graph

25 Commits (master)

Author SHA1 Message Date
Junegunn Choi 4bedd33c59
Refactor the code to remove global variables 2 weeks ago
Junegunn Choi c30e486b64
Further performance improvements by removing unnecessary copies 2 months ago
Junegunn Choi 0d06c28b19
Fix delimiter regex to properly support caret (^)
Fix #2861
2 years ago
freddii 58ac1fb2fa
Fix typos in source code (#2322) 3 years ago
Christian Muehlhaeuser a1260feeed Code cleanup (#1640)
- Replaced time.Now().Sub() with time.Since()
- Replaced unnecessary string/byte slice conversions
- Removed obsolete return and value assignment in range loop
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 af809c9661
Minor refactorings 7 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 37dc273148
Micro-optimizations
- Make structs smaller
- Introduce Result struct and use it to represent matched items instead of
  reusing Item struct for that purpose
- Avoid unnecessary memory allocation
- Avoid growing slice from the initial capacity
- Code cleanup
8 years ago
Junegunn Choi 01ee335521
Remove duplicate code 8 years ago
Junegunn Choi d9c8a9a880
[perf] Remove memory copy when using string delimiter 8 years ago
Junegunn Choi ddc7bb9064
[perf] Optimize AWK-style tokenizer for --nth
Approx. 50% less memory footprint and 40% improvement in query time
8 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 c35d98dc42 Nullify --nth option when it's irrelevant 9 years ago
Junegunn Choi cd847affb7 Reorganize source code 9 years ago
Junegunn Choi 7a2bc2cada Lint 9 years ago
Junegunn Choi d303c5b3eb Minor refactoring 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