frostfs-node/pkg/services/object/put/pool.go

25 lines
362 B
Go
Raw Normal View History

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)
}