TDengine/tools/keeper/util/pool/bytes.go
2024-10-17 17:04:34 +08:00

23 lines
322 B
Go

package pool
import (
"bytes"
"sync"
)
var bytesBufferPool sync.Pool
func init() {
bytesBufferPool.New = func() interface{} {
return &bytes.Buffer{}
}
}
func BytesPoolGet() *bytes.Buffer {
return bytesBufferPool.Get().(*bytes.Buffer)
}
func BytesPoolPut(b *bytes.Buffer) {
b.Reset()
bytesBufferPool.Put(b)
}