2022-12-06 10:25:19 +00:00
|
|
|
package putsvc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"sync"
|
|
|
|
)
|
|
|
|
|
|
|
|
const defaultAllocSize = 1024
|
|
|
|
|
|
|
|
var putBytesPool = &sync.Pool{
|
2023-02-21 11:42:45 +00:00
|
|
|
New: func() any { return make([]byte, 0, defaultAllocSize) },
|
2022-12-06 10:25:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func getPayload() []byte {
|
|
|
|
return putBytesPool.Get().([]byte)
|
|
|
|
}
|
|
|
|
|
|
|
|
func putPayload(p []byte) {
|
|
|
|
//nolint:staticcheck
|
|
|
|
putBytesPool.Put(p[:0])
|
|
|
|
}
|