Skip to content

Commit

Permalink
not add non-equal cap bytes back to pool (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
wongoo authored Dec 30, 2019
1 parent 573f790 commit 3d7d91f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bytes/bytes_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ func (bp *BytesPool) AcquireBytes(size int) []byte {

// ReleaseBytes ...
func (bp *BytesPool) ReleaseBytes(buf []byte) {
idx := bp.findIndex(cap(buf))
if idx >= bp.length {
bufCap := cap(buf)
idx := bp.findIndex(bufCap)
if idx >= bp.length || bp.sizes[idx] != bufCap {
return
}

Expand Down

0 comments on commit 3d7d91f

Please sign in to comment.