Commit 0a5f16ec authored by Steven Allen's avatar Steven Allen

preallocate Batch's blocks buffer on commit.

It's probably safe to assume that this buffer will be about the same time each
flush.

This could cause 1 extra allocation (if this is the last commit) but that's
unlikely to be an issue.

License: MIT
Signed-off-by: default avatarSteven Allen <steven@stebalien.com>
parent 88e6deb4
......@@ -43,7 +43,8 @@ func (t *Batch) processResults() {
}
func (t *Batch) asyncCommit() {
if len(t.blocks) == 0 || t.commitError != nil {
numBlocks := len(t.blocks)
if numBlocks == 0 || t.commitError != nil {
return
}
if t.activeCommits >= ParallelBatchCommits {
......@@ -61,7 +62,7 @@ func (t *Batch) asyncCommit() {
}(t.blocks)
t.activeCommits++
t.blocks = nil
t.blocks = make([]blocks.Block, 0, numBlocks)
t.size = 0
return
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment