forked from TrueCloudLab/frostfs-node
Dmitrii Stepanov
cecea8053a
Resolve staticcheck linter for putBytesPool Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
24 lines
362 B
Go
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)
|
|
}
|