restic/internal/repository/pool.go

22 lines
276 B
Go
Raw Normal View History

package repository
2015-04-26 14:46:15 +02:00
import (
"sync"
2015-07-08 00:55:58 +02:00
"github.com/restic/chunker"
2015-04-26 14:46:15 +02:00
)
var bufPool = sync.Pool{
New: func() interface{} {
2018-04-08 21:57:52 +02:00
return make([]byte, chunker.MaxSize/3)
2015-04-26 14:46:15 +02:00
},
}
func getBuf() []byte {
return bufPool.Get().([]byte)
}
func freeBuf(data []byte) {
bufPool.Put(data)
}