Skip to content

Commit

Permalink
chore: resolve the lint issue of staticcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
panjf2000 committed Dec 9, 2021
1 parent 302b2e5 commit e8f7a87
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/pool/byteslice/byteslice.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ func (p *Pool) Get(size int) []byte {
}
idx := index(uint32(size))
if v := p.pools[idx].Get(); v != nil {
return v.([]byte)[:size]
bp := v.(*[]byte)
return (*bp)[:size]
}
return make([]byte, 1<<idx)[:size]
}
Expand All @@ -62,7 +63,7 @@ func (p *Pool) Put(buf []byte) {
if size != 1<<idx { // this byte slice is not from Pool.Get(), put it into the previous interval of idx
idx--
}
p.pools[idx].Put(buf)
p.pools[idx].Put(&buf)
}

func index(n uint32) uint32 {
Expand Down

0 comments on commit e8f7a87

Please sign in to comment.