From e13bafc1abaea9a9f3142eb58be1e977ca97e114 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 2 Aug 2015 14:25:57 +0900 Subject: Performance fix - unnecessary rune convertion on --ansi > time cat /tmp/list | fzf-0.10.1-darwin_amd64 --ansi -fqwerty > /dev/null real 0m4.364s user 0m8.231s sys 0m0.820s > time cat /tmp/list | fzf --ansi -fqwerty > /dev/null real 0m4.624s user 0m5.755s sys 0m0.732s --- src/chunklist_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/chunklist_test.go') diff --git a/src/chunklist_test.go b/src/chunklist_test.go index faaf04fe..26795ef2 100644 --- a/src/chunklist_test.go +++ b/src/chunklist_test.go @@ -6,8 +6,8 @@ import ( ) func TestChunkList(t *testing.T) { - cl := NewChunkList(func(s []rune, i int) *Item { - return &Item{text: s, rank: Rank{0, 0, uint32(i * 2)}} + cl := NewChunkList(func(s []byte, i int) *Item { + return &Item{text: []rune(string(s)), rank: Rank{0, 0, uint32(i * 2)}} }) // Snapshot @@ -17,8 +17,8 @@ func TestChunkList(t *testing.T) { } // Add some data - cl.Push([]rune("hello")) - cl.Push([]rune("world")) + cl.Push([]byte("hello")) + cl.Push([]byte("world")) // Previously created snapshot should remain the same if len(snapshot) > 0 { @@ -46,7 +46,7 @@ func TestChunkList(t *testing.T) { // Add more data for i := 0; i < chunkSize*2; i++ { - cl.Push([]rune(fmt.Sprintf("item %d", i))) + cl.Push([]byte(fmt.Sprintf("item %d", i))) } // Previous snapshot should remain the same @@ -64,8 +64,8 @@ func TestChunkList(t *testing.T) { t.Error("Unexpected number of items") } - cl.Push([]rune("hello")) - cl.Push([]rune("world")) + cl.Push([]byte("hello")) + cl.Push([]byte("world")) lastChunkCount := len(*snapshot[len(snapshot)-1]) if lastChunkCount != 2 { -- cgit v1.2.3