mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-07 20:31:41 +00:00
18 lines
272 B
Go
18 lines
272 B
Go
|
package pool
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"sync"
|
||
|
)
|
||
|
|
||
|
var bufferPool = sync.Pool{New: func() interface{} { return &bytes.Buffer{} }}
|
||
|
|
||
|
func GetBuffer() *bytes.Buffer {
|
||
|
return bufferPool.Get().(*bytes.Buffer)
|
||
|
}
|
||
|
|
||
|
func PutBuffer(buf *bytes.Buffer) {
|
||
|
buf.Reset()
|
||
|
bufferPool.Put(buf)
|
||
|
}
|