frostfs-node/pkg/services/object/put/pool.go
Dmitrii Stepanov cecea8053a [] putsvc: Refactor streamer pool
Resolve staticcheck linter for putBytesPool

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
2023-04-03 15:58:11 +00:00

24 lines
362 B
Go

package putsvc
import (
"sync"
)
const defaultAllocSize = 1024
type payload struct {
Data []byte
}
var putBytesPool = &sync.Pool{
New: func() any { return &payload{Data: make([]byte, 0, defaultAllocSize)} },
}
func getPayload() *payload {
return putBytesPool.Get().(*payload)
}
func putPayload(p *payload) {
p.Data = p.Data[:0]
putBytesPool.Put(p)
}