Skip to content

Commit 3d7d91f

Browse files
authored
not add non-equal cap bytes back to pool (#17)
1 parent 573f790 commit 3d7d91f

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

bytes/bytes_pool.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ func (bp *BytesPool) AcquireBytes(size int) []byte {
7272

7373
// ReleaseBytes ...
7474
func (bp *BytesPool) ReleaseBytes(buf []byte) {
75-
idx := bp.findIndex(cap(buf))
76-
if idx >= bp.length {
75+
bufCap := cap(buf)
76+
idx := bp.findIndex(bufCap)
77+
if idx >= bp.length || bp.sizes[idx] != bufCap {
7778
return
7879
}
7980

0 commit comments

Comments
 (0)