Skip to content

Commit

Permalink
Remove slicepool
Browse files Browse the repository at this point in the history
  • Loading branch information
Ibrahim Jarif committed Mar 4, 2020
1 parent 34af954 commit c5e3d30
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions table/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,29 +117,16 @@ func NewTableBuilder(opts Options) *Builder {
}
return b
}

var slicePool = sync.Pool{
New: func() interface{} {
// Make 4 KB blocks for reuse.
b := make([]byte, 0, 4<<10)
return &b
},
}

func (b *Builder) handleBlock() {
defer b.wg.Done()
for item := range b.blockChan {
// Extract the block.
blockBuf := item.data[item.start:item.end]
var dst *[]byte
// Compress the block.
if b.opt.Compression != options.None {
var err error

dst = slicePool.Get().(*[]byte)
*dst = (*dst)[:0]

blockBuf, err = b.compressData(*dst, blockBuf)
blockBuf, err = b.compressData(nil, blockBuf)
y.Check(err)
}
if b.shouldEncrypt() {
Expand All @@ -165,10 +152,6 @@ func (b *Builder) handleBlock() {

// Fix the boundary of the block.
item.end = item.start + uint32(len(blockBuf))

if dst != nil {
slicePool.Put(dst)
}
}
}

Expand Down

0 comments on commit c5e3d30

Please sign in to comment.