reduce allocations (also pulls in updated ironwood to do the same)

This commit is contained in:
Arceliar 2023-05-21 12:38:16 -05:00
parent 52709696a5
commit 8b5add5301
4 changed files with 24 additions and 5 deletions

17
src/core/pool.go Normal file
View file

@ -0,0 +1,17 @@
package core
import "sync"
var bytePool = sync.Pool{New: func() interface{} { return []byte(nil) }}
func allocBytes(size int) []byte {
bs := bytePool.Get().([]byte)
if cap(bs) < size {
bs = make([]byte, size)
}
return bs[:size]
}
func freeBytes(bs []byte) {
bytePool.Put(bs[:0])
}