From 1d4057c20907b7d263d6f2b8cb4350a024859dfe Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 14 Aug 2016 00:39:44 +0900 Subject: [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. --- src/merger_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/merger_test.go') 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} } -- cgit v1.2.3