summaryrefslogtreecommitdiffstats
path: root/src/merger_test.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2016-08-14 00:39:44 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2016-08-14 00:41:30 +0900
commit1d4057c20907b7d263d6f2b8cb4350a024859dfe (patch)
treeadb1edd9c4f1806cd65f8c5117645c22618c7301 /src/merger_test.go
parent822b86942c4ffb0dbf7fd096584d2970675f3ebc (diff)
[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.
Diffstat (limited to 'src/merger_test.go')
-rw-r--r--src/merger_test.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/merger_test.go b/src/merger_test.go
index 472e2048..f62f9759 100644
--- a/src/merger_test.go
+++ b/src/merger_test.go
@@ -5,6 +5,8 @@ import (
"math/rand"
"sort"
"testing"
+
+ "github.com/junegunn/fzf/src/util"
)
func assert(t *testing.T, cond bool, msg ...string) {
@@ -22,7 +24,7 @@ func randItem() *Item {
offsets[idx] = Offset{sidx, eidx}
}
return &Item{
- text: []rune(str),
+ text: util.RunesToChars([]rune(str)),
rank: buildEmptyRank(rand.Int31()),
offsets: offsets}
}