summaryrefslogtreecommitdiffstats
path: root/src/core.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-04-17 22:23:52 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-04-17 22:23:52 +0900
commit2fe1e28220c543ddbf4e12ee7396e44ee85ad8e0 (patch)
tree82c77b5e639cd66b941356788bcb8e0e053949be /src/core.go
parent288131ac5a895ba335681339d85ee039557490da (diff)
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.
Diffstat (limited to 'src/core.go')
-rw-r--r--src/core.go6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/core.go b/src/core.go
index b56fbf64..7230cffd 100644
--- a/src/core.go
+++ b/src/core.go
@@ -34,9 +34,6 @@ import (
"github.com/junegunn/fzf/src/util"
)
-const coordinatorDelayMax time.Duration = 100 * time.Millisecond
-const coordinatorDelayStep time.Duration = 10 * time.Millisecond
-
func initProcs() {
runtime.GOMAXPROCS(runtime.NumCPU())
}
@@ -99,8 +96,9 @@ func Run(options *Options) {
} else {
chunkList = NewChunkList(func(data *string, index int) *Item {
tokens := Tokenize(data, opts.Delimiter)
+ trans := Transform(tokens, opts.WithNth)
item := Item{
- text: Transform(tokens, opts.WithNth).whole,
+ text: joinTokens(trans),
origText: data,
index: uint32(index),
colors: nil,