Do not drop on the floor small buffers
Currently if a buffer from the buffer is too small to satisfy its request then we simply drop it and allocate a new one. This change puts it back in the pool and then allocates a new one.pull/9461/head
parent
6d008c3453
commit
228e17d79b
|
@ -13,6 +13,7 @@ func getBuf(size int) *[]byte {
|
|||
}
|
||||
buf := x.(*[]byte)
|
||||
if cap(*buf) < size {
|
||||
bufPool.Put(x)
|
||||
b := make([]byte, size)
|
||||
return &b
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue