Skip to content

Commit 22becd6

Browse files
committed
Yet another minor improvement for single-item batches
1 parent 1edf9b2 commit 22becd6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

batch.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ func (b *Batch) Push(record interface{}) error {
6969
return errors.New("batch not initialized")
7070
}
7171

72+
// if only one item is in the batch, don't even bother storing it
73+
if b.batchSize == 1 {
74+
return b.pushHandler([]interface{}{record})
75+
}
76+
7277
// lock around batch processing
7378
b.mutex.Lock()
7479

@@ -94,7 +99,6 @@ func (b *Batch) Push(record interface{}) error {
9499
return err
95100
}
96101

97-
// dereference batch to clue GC, unless user wants to retain data
98102
batch = nil
99103
} else {
100104

0 commit comments

Comments
 (0)