pools: Add a pool for buffers

This commit is contained in:
Tom Wiesing 2023-01-24 11:04:34 +01:00
parent a63bb2f669
commit 598de5b289
No known key found for this signature in database
6 changed files with 56 additions and 28 deletions

View file

@ -1,19 +0,0 @@
package pools
import (
"strings"
"sync"
)
var builders = sync.Pool{
New: func() any { return new(strings.Builder) },
}
func GetBuilder() *strings.Builder {
return builders.Get().(*strings.Builder)
}
func ReleaseBuilder(builder *strings.Builder) {
builder.Reset()
builders.Put(builder)
}