提交 9de031b4 作者: 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: 's avatarSteven Allen <steven@stebalien.com>
上级 e41848c5
......@@ -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 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论