mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-14 05:11:17 +08:00
18 lines
264 B
Go
18 lines
264 B
Go
package pool
|
|
|
|
import (
|
|
"bytes"
|
|
"sync"
|
|
)
|
|
|
|
var bufferPool = sync.Pool{New: func() any { return &bytes.Buffer{} }}
|
|
|
|
func GetBuffer() *bytes.Buffer {
|
|
return bufferPool.Get().(*bytes.Buffer)
|
|
}
|
|
|
|
func PutBuffer(buf *bytes.Buffer) {
|
|
buf.Reset()
|
|
bufferPool.Put(buf)
|
|
}
|