mirror of
https://github.com/taosdata/TDengine
synced 2026-05-24 10:09:01 +00:00
23 lines
322 B
Go
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)
|
|
}
|