summaryrefslogtreecommitdiffstats
path: root/src/chunklist.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-08-02 14:00:18 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-08-02 14:00:18 +0900
commit0ea66329b84cc6e4f8ff61ee99c00bb238070247 (patch)
tree72c3bc62ec491246390b56b2aac5b33645839503 /src/chunklist.go
parent634670e3ea51a2fa1498a3de0c074b819828e2d8 (diff)
Performance tuning - eager rune array conversion
> 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
Diffstat (limited to 'src/chunklist.go')
-rw-r--r--src/chunklist.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/chunklist.go b/src/chunklist.go
index ee52d321..c20ffd43 100644
--- a/src/chunklist.go
+++ b/src/chunklist.go
@@ -7,7 +7,7 @@ type Chunk []*Item // >>> []Item
// ItemBuilder is a closure type that builds Item object from a pointer to a
// string and an integer
-type ItemBuilder func(*string, int) *Item
+type ItemBuilder func([]rune, int) *Item
// ChunkList is a list of Chunks
type ChunkList struct {
@@ -26,7 +26,7 @@ func NewChunkList(trans ItemBuilder) *ChunkList {
trans: trans}
}
-func (c *Chunk) push(trans ItemBuilder, data *string, index int) bool {
+func (c *Chunk) push(trans ItemBuilder, data []rune, index int) bool {
item := trans(data, index)
if item != nil {
*c = append(*c, item)
@@ -53,7 +53,7 @@ func CountItems(cs []*Chunk) int {
}
// Push adds the item to the list
-func (cl *ChunkList) Push(data string) bool {
+func (cl *ChunkList) Push(data []rune) bool {
cl.mutex.Lock()
defer cl.mutex.Unlock()
@@ -62,7 +62,7 @@ func (cl *ChunkList) Push(data string) bool {
cl.chunks = append(cl.chunks, &newChunk)
}
- if cl.lastChunk().push(cl.trans, &data, cl.count) {
+ if cl.lastChunk().push(cl.trans, data, cl.count) {
cl.count++
return true
}