summaryrefslogtreecommitdiff
path: root/src/algo/algo.go
AgeCommit message (Collapse)Author
2025-07-03Normalize halfwidth and fullwidth characers for matchingJunegunn Choi
2025-06-26Fix exact boundary match with --scheme=path or --tiebreak endJunegunn Choi
Fix #4438
2025-02-17Normalize char before pattern lookup (#4252)Alexei Șerșun
There is an edge-case in FuzzyMatchV1 during backward scan, related to normalization: if string is initially denormalized (e.g. Unicode symbol), backward scan will proceed further to the next char; however, when the score is computed, the string is normalized first, then scanned based on the pattern. This leads to accessing pattern index increment, which itself leads to out-of-bound index access, resulting in a panic. To illustrate the process, here's the sequence of operations when search is perfored: 1. during backward scan by "minim" pattern ``` xxxxx Minímal example ^^^^^^^^^^^^ |||||||||||| miniiiiiiiim <- compute score for this substring ``` 2. during compute score by "minim" pattern ``` Minímal exam minimal exam <- normalize chars before computing the score ^^^^^^ |||||| minim <- at this point the pattern is already fully scanned and index is out-of-the-bound ``` In this commit the char is normalized during backward scan, to detect properly the boundaries for the pattern.
2025-01-20Fix a non-constant format string (#4189)Elliott Sales de Andrade
Go 1.24 now has a vet check about this that causes `go test` to fail: https://github.com/golang/go/issues/60529
2024-08-29Underscore boundaries should be ranked lowerJunegunn Choi
2024-08-29Implement exact-boundary match typeJunegunn Choi
Close #3963
2024-05-07Refactor the code so that fzf can be used as a library (#3769)Junegunn Choi
2024-04-14Improve search performance by limiting the search scopeJunegunn Choi
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.
2024-04-14Improve search performance by pre-calculating bonus matrixJunegunn Choi
This gives yet another 5% boost.
2024-04-14Improve search performance by pre-calculating character classesJunegunn Choi
This simple optmization can give more than 15% performance boost in some scenarios.
2024-02-22Fix missing bonus score on a delimiter characterJunegunn Choi
Fix #3645
2023-06-17Use strings.ContainsRune instead (#3335)guangwu
2022-12-04Fix inconsistent bonus points in exact matchJunegunn Choi
Exact match would assign a different bonus point to the first character when non-default --scheme was used. Fix #3073
2022-08-28Add --scheme=[default|path|history] option to choose scoring schemeJunegunn Choi
Close #2909 Close #2930
2022-08-02Tweak bonus points to word boundariesJunegunn Choi
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
2021-08-17Fix spelling error (Extention -> Extension) (#2589)Keating950
2020-03-01Fix prefix/suffix/equal matcher to trim whitespacesJunegunn Choi
- 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
2019-11-05Improvements to code quality and readability (#1737)Alexandr
* 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 ^
2017-08-26Remove an unnecessary code branchJunegunn Choi
2017-08-26Remove bound checkings in inner loopsJunegunn Choi
2017-08-20Minor optimization of FuzzyMatchV2Junegunn Choi
Calculate the first row of the score matrix during phase 2
2017-08-20Extract debug code from FuzzyMatchV2Junegunn Choi
2017-08-20Remove unused clear arguments of alloc16 and alloc32Junegunn Choi
2017-08-20Pass util.Chars by pointerJunegunn Choi
2017-08-19Delay slab allocationJunegunn Choi
2017-08-18Limit search scope of uppercase letterJunegunn Choi
2017-08-12Update FuzzyMatchV1 to use skip optimization used in V2Junegunn Choi
2017-07-30Optimize exact match by applying the same trick for fuzzy matchJunegunn Choi
2017-07-30Optimize fuzzy search performance for ASCII stringsJunegunn Choi
2017-07-16Reduce memory footprint of Item structJunegunn Choi
2017-01-09Normalize pattern string before passing it to Algo functionJunegunn Choi
2017-01-09Add --normalize option to normalize latin script charactersJunegunn Choi
Close #790
2016-09-21Fix panic when pattern occurs after 2^15-th columnJunegunn Choi
Fix #666
2016-09-18Revise ranking algorithmJunegunn Choi
2016-09-10Update algo.goishanray
2016-08-19Micro-optimizationsJunegunn Choi
- 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
2016-08-18Inline function calls in tight loopsJunegunn Choi
By only using leaf functions
2016-08-14[perf] evaluateBonus can start from sidx - 1Junegunn Choi
2016-08-14[perf] Avoid allocating rune array for ascii stringJunegunn Choi
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.
2016-04-23Apply new ranking algorithm to exact match as wellJunegunn Choi
2016-04-16Enhanced ranking algorithmJunegunn Choi
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".
2015-09-12Fix #344 - Backward scan when `--tiebreak=end`Junegunn Choi
2015-08-02GoLintJunegunn Choi
2015-08-02Performance tuning - eager rune array conversionJunegunn Choi
> 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
2015-06-08Allow ^EqualMatch$Junegunn Choi
2015-04-21Fix #209 - Invalid mutation of input on case conversionJunegunn Choi
2015-04-17Improvements in performance and memory usageJunegunn Choi
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.
2015-04-14Fix Unicode case handling (#186)Junegunn Choi
2015-03-19Fix #149 - panic on empty string filterJunegunn Choi
2015-01-12Reorganize source codeJunegunn Choi