frostfs-node/pkg/services/object/put/pool.go
Evgenii Stratonikov 04b5ec759b [#2139] object/put: Use sync.Pool for temporary payloads
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2022-12-30 11:07:35 +03:00

20 lines
315 B
Go

package putsvc
import (
"sync"
)
const defaultAllocSize = 1024
var putBytesPool = &sync.Pool{
New: func() interface{} { return make([]byte, 0, defaultAllocSize) },
}
func getPayload() []byte {
return putBytesPool.Get().([]byte)
}
func putPayload(p []byte) {
//nolint:staticcheck
putBytesPool.Put(p[:0])
}