Commit Graph

47 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
Junegunn Choi e86b81bbf5
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.
1 month ago
Junegunn Choi a5447b8b75
Improve search performance by pre-calculating bonus matrix
This gives yet another 5% boost.
1 month ago
Junegunn Choi 7ce6452d83
Improve search performance by pre-calculating character classes
This simple optmization can give more than 15% performance boost
in some scenarios.
1 month ago
Junegunn Choi 99a7beba57
Fix missing bonus score on a delimiter character
Fix #3645
3 months ago
guangwu 4772bd8d4c
Use strings.ContainsRune instead (#3335) 11 months ago
Junegunn Choi 6b207bbf2b
Fix inconsistent bonus points in exact match
Exact match would assign a different bonus point to the first character
when non-default --scheme was used.

Fix #3073
1 year ago
Junegunn Choi 6fb41a202a
Add --scheme=[default|path|history] option to choose scoring scheme
Close #2909
Close #2930
2 years ago
Junegunn Choi c3a7a24eea
Tweak bonus points to word boundaries
Close https://github.com/junegunn/fzf.vim/issues/1004

  # jobs/latency.js is favored over job_latency.js
  printf 'job_latency.js\njobs/latency.js' | fzf -qlatency
2 years ago
Keating950 3f90fb42d8
Fix spelling error (Extention -> Extension) (#2589) 3 years ago
Khon Trieu 4ec144c969
Accented character normalization for Vietnamese characters (#2090)
Fix #2088
4 years ago
Junegunn Choi 4c9cab3f8a
Fix prefix/suffix/equal matcher to trim whitespaces
- Prefix matcher will trim leading whitespaces only when the pattern
  doesn't start with a whitespace
- Suffix matcher will trim trailing whitespaces only when the pattern
  doesn't end with a whitespace
- Equal matcher will trim leading whitespaces only when the pattern
  doesn't start with a whitespace, and trim trailing whitespaces only
  when the pattern doesn't end with a whitespace

Previously, only suffix matcher would trim whitespaces unconditionally.

Fix #1894
4 years ago
Alexandr b4cccf23d4 Improvements to code quality and readability (#1737)
* Remove 1 unused field and 3 unused functions

unused elements fount by running
golangci-lint run --disable-all --enable unused

src/result.go:19:2: field `index` is unused (unused)
        index  int32
        ^
src/tui/light.go:716:23: func `(*LightWindow).stderr` is unused (unused)
func (w *LightWindow) stderr(str string) {
                      ^
src/terminal.go:1015:6: func `numLinesMax` is unused (unused)
func numLinesMax(str string, max int) int {
     ^
src/tui/tui.go:167:20: func `ColorPair.is24` is unused (unused)
func (p ColorPair) is24() bool {
                   ^

* Address warnings from "gosimple" linter

src/options.go:389:83: S1003: should use strings.Contains(str, ",,,") instead (gosimple)
        if str == "," || strings.HasPrefix(str, ",,") || strings.HasSuffix(str, ",,") || strings.Index(str, ",,,") >= 0 {
                                                                                         ^
src/options.go:630:18: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
        executeRegexp = regexp.MustCompile(
                        ^
src/terminal.go:29:16: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
        placeholder = regexp.MustCompile("\\\\?(?:{[+sf]*[0-9,-.]*}|{q}|{\\+?f?nf?})")
                      ^
src/terminal_test.go:92:10: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
        regex = regexp.MustCompile("\\w+")
                ^

* Address warnings from "staticcheck" linter

src/algo/algo.go:374:2: SA4006: this value of `offset32` is never used (staticcheck)
        offset32, T := alloc32(offset32, slab, N)
        ^
src/algo/algo.go:456:2: SA4006: this value of `offset16` is never used (staticcheck)
        offset16, C := alloc16(offset16, slab, width*M)
        ^
src/tui/tui.go:119:2: SA9004: only the first constant in this group has an explicit type (staticcheck)
        colUndefined Color = -2
        ^
5 years ago
Junegunn Choi 159699b5d7
Remove an unnecessary code branch 7 years ago
Junegunn Choi 71fdb99a07
Remove bound checkings in inner loops 7 years ago
Junegunn Choi 941b0a0ff7
Minor optimization of FuzzyMatchV2
Calculate the first row of the score matrix during phase 2
7 years ago
Junegunn Choi 6aae12288e
Extract debug code from FuzzyMatchV2 7 years ago
Junegunn Choi 302cc552ef
Remove unused clear arguments of alloc16 and alloc32 7 years ago
Junegunn Choi a2a4df0886
Pass util.Chars by pointer 7 years ago
Junegunn Choi c304fc4333
Delay slab allocation 7 years ago
Junegunn Choi 6977cf268f
Limit search scope of uppercase letter 7 years ago
Junegunn Choi 6bc592e6c9
Update FuzzyMatchV1 to use skip optimization used in V2 7 years ago
Junegunn Choi 8db3345c2f
Optimize exact match by applying the same trick for fuzzy match 7 years ago
Junegunn Choi 69aa2fea68
Optimize fuzzy search performance for ASCII strings 7 years ago
Junegunn Choi bd98f988f0
Further reduce unnecessary rune array conversion
I was too quick to release 0.16.9, this commit makes --ansi processing
even faster.
7 years ago
Junegunn Choi 9e85cba0d0
Reduce memory footprint of Item struct 7 years ago
Junegunn Choi a16d8f66a9
Normalize pattern string before passing it to Algo function 7 years ago
Junegunn Choi 45793d75c2
Add --normalize option to normalize latin script characters
Close #790
7 years ago
Junegunn Choi 791076d366
Fix panic when pattern occurs after 2^15-th column
Fix #666
8 years ago
Junegunn Choi 2fc7c18747
Revise ranking algorithm 8 years ago
ishanray f44d40f6b4 Update algo.go 8 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 0e0de29b87
Inline function calls in tight loops
By only using leaf functions
8 years ago
Junegunn Choi 41e916a511
[perf] evaluateBonus can start from sidx - 1 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 4bde8de63f Apply new ranking algorithm to exact match as well 8 years ago
Junegunn Choi 2f6d23b91e Enhanced ranking algorithm
Based on the patch by Matt Westcott (@mjwestcott).
But with a more conservative approach:
- Does not use linearly increasing penalties; It is agreed upon that we
  should prefer matching characters at the beginnings of the words, but
  it's not always clear that the relevance is inversely proportional to
  the distance from the beginning.
- The approach here is more conservative in that the bonus is never
  large enough to override the matchlen, so it can be thought of as the
  first implicit tiebreak criterion.
- One may argue the change breaks the contract of --tiebreak, but the
  judgement depends on the definition of "tie".
8 years ago
Matt Westcott 2ca704405a Fix algorithm tests 8 years ago
Junegunn Choi 64443221aa Fix #344 - Backward scan when `--tiebreak=end` 9 years ago
Junegunn Choi ae87f6548a GoLint 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 0be4cead20 Allow ^EqualMatch$ 9 years ago
Junegunn Choi 3f0e6a5806 Fix #209 - Invalid mutation of input on case conversion 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 5c25984ea0 Fix Unicode case handling (#186) 9 years ago
Junegunn Choi a723977b9f Fix #149 - panic on empty string filter 9 years ago
Junegunn Choi cd847affb7 Reorganize source code 9 years ago