internal/buffer: initial implementation of the package

pull/865/head
Panagiotis Siatras 2 years ago
parent e82b21c1cb
commit 2fd84227f0
No known key found for this signature in database
GPG Key ID: 529695F03A572804

@ -0,0 +1,23 @@
// Package buffer implements a reusable buffer pool.
package buffer
import (
"bytes"
"sync"
)
func Get() *bytes.Buffer {
return pool.Get().(*bytes.Buffer)
}
func Put(b *bytes.Buffer) {
b.Reset()
pool.Put(b)
}
var pool = sync.Pool{
New: func() interface{} {
return new(bytes.Buffer)
},
}
Loading…
Cancel
Save