mirror of
https://github.com/CPunch/gopenfusion.git
synced 2024-11-14 03:50:05 +00:00
20 lines
255 B
Go
20 lines
255 B
Go
package pool
|
|
|
|
import (
|
|
"bytes"
|
|
"sync"
|
|
)
|
|
|
|
var allocator = sync.Pool{
|
|
New: func() any { return new(bytes.Buffer) },
|
|
}
|
|
|
|
func Get() *bytes.Buffer {
|
|
return allocator.Get().(*bytes.Buffer)
|
|
}
|
|
|
|
func Put(buf *bytes.Buffer) {
|
|
buf.Reset()
|
|
allocator.Put(buf)
|
|
}
|