mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 23:34:02 +03:00
FILE / ScuroNeko/mtg
mtglib/internal/tls/fake/bytes_pool.go
Исходный файл и его история в репозитории.
22 lines
270 B
Go
22 lines
270 B
Go
package fake
|
|
|
|
import (
|
|
"bytes"
|
|
"sync"
|
|
)
|
|
|
|
var bytesPool = sync.Pool{
|
|
New: func() any {
|
|
return &bytes.Buffer{}
|
|
},
|
|
}
|
|
|
|
func acquireBuffer() *bytes.Buffer {
|
|
return bytesPool.Get().(*bytes.Buffer)
|
|
}
|
|
|
|
func releaseBuffer(b *bytes.Buffer) {
|
|
b.Reset()
|
|
bytesPool.Put(b)
|
|
}
|