Skip to content

Commit

Permalink
rpc_util: return unused buffers to memory pool
Browse files Browse the repository at this point in the history
  • Loading branch information
hueypark committed May 23, 2023
1 parent 5535416 commit 2678efb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion shared_buffer_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ func (p *bufferPool) Get(size int) []byte {
bs := p.Pool.Get().(*[]byte)

if cap(*bs) < size {
*bs = make([]byte, size)
p.Pool.Put(bs)

return make([]byte, size)
}

return (*bs)[:size]
Expand Down

0 comments on commit 2678efb

Please sign in to comment.