diff options
Diffstat (limited to 'src/chunklist.go')
-rw-r--r-- | src/chunklist.go | 18 |
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 |