summaryrefslogtreecommitdiffstats
path: root/src/chunklist.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2017-07-15 12:28:29 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2017-07-16 23:34:32 +0900
commitd4f3d5a16423fbf039644f04516c052d1654326c (patch)
tree2cb3f9519a23e9e9c162d135636d9f99373deadc /src/chunklist.go
parent7b5ccc45bc76f289fe2c48cf91e895b9ca99b1e2 (diff)
Remove pointer indirection by changing Chunk definition
Diffstat (limited to 'src/chunklist.go')
-rw-r--r--src/chunklist.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/chunklist.go b/src/chunklist.go
index a953fae9..1144274c 100644
--- a/src/chunklist.go
+++ b/src/chunklist.go
@@ -2,12 +2,12 @@ package fzf
import "sync"
-// Chunk is a list of Item pointers whose size has the upper limit of chunkSize
-type Chunk []*Item // >>> []Item
+// Chunk is a list of Items whose size has the upper limit of chunkSize
+type Chunk []Item
// ItemBuilder is a closure type that builds Item object from a pointer to a
// string and an integer
-type ItemBuilder func([]byte, int) *Item
+type ItemBuilder func([]byte, int) Item
// ChunkList is a list of Chunks
type ChunkList struct {
@@ -28,11 +28,11 @@ func NewChunkList(trans ItemBuilder) *ChunkList {
func (c *Chunk) push(trans ItemBuilder, data []byte, index int) bool {
item := trans(data, index)
- if item != nil {
- *c = append(*c, item)
- return true
+ if item.Nil() {
+ return false
}
- return false
+ *c = append(*c, item)
+ return true
}
// IsFull returns true if the Chunk is full
@@ -58,7 +58,7 @@ func (cl *ChunkList) Push(data []byte) bool {
defer cl.mutex.Unlock()
if len(cl.chunks) == 0 || cl.lastChunk().IsFull() {
- newChunk := Chunk(make([]*Item, 0, chunkSize))
+ newChunk := Chunk(make([]Item, 0, chunkSize))
cl.chunks = append(cl.chunks, &newChunk)
}