summaryrefslogtreecommitdiffstats
path: root/src/chunklist.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-07-22 03:21:20 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-07-22 03:21:20 +0900
commitf469c25730aaa711b8327be068514c944074cce4 (patch)
tree3c386987c2bb227188b86f3e4438430262a7c6ca /src/chunklist.go
parent18469b69549f1efd5294ebeb357d1773fc3a241e (diff)
Add --header-lines option
Diffstat (limited to 'src/chunklist.go')
-rw-r--r--src/chunklist.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/chunklist.go b/src/chunklist.go
index 52084f2f..ee52d321 100644
--- a/src/chunklist.go
+++ b/src/chunklist.go
@@ -26,8 +26,13 @@ func NewChunkList(trans ItemBuilder) *ChunkList {
trans: trans}
}
-func (c *Chunk) push(trans ItemBuilder, data *string, index int) {
- *c = append(*c, trans(data, index))
+func (c *Chunk) push(trans ItemBuilder, data *string, index int) bool {
+ item := trans(data, index)
+ if item != nil {
+ *c = append(*c, item)
+ return true
+ }
+ return false
}
// IsFull returns true if the Chunk is full
@@ -48,7 +53,7 @@ func CountItems(cs []*Chunk) int {
}
// Push adds the item to the list
-func (cl *ChunkList) Push(data string) {
+func (cl *ChunkList) Push(data string) bool {
cl.mutex.Lock()
defer cl.mutex.Unlock()
@@ -57,8 +62,11 @@ func (cl *ChunkList) Push(data string) {
cl.chunks = append(cl.chunks, &newChunk)
}
- cl.lastChunk().push(cl.trans, &data, cl.count)
- cl.count++
+ if cl.lastChunk().push(cl.trans, &data, cl.count) {
+ cl.count++
+ return true
+ }
+ return false
}
// Snapshot returns immutable snapshot of the ChunkList