github.com/fawick/restic@v0.1.1-0.20171126184616-c02923fbfc79/internal/repository/pool.go (about) 1 package repository 2 3 import ( 4 "sync" 5 6 "github.com/restic/chunker" 7 ) 8 9 var bufPool = sync.Pool{ 10 New: func() interface{} { 11 return make([]byte, chunker.MinSize) 12 }, 13 } 14 15 func getBuf() []byte { 16 return bufPool.Get().([]byte) 17 } 18 19 func freeBuf(data []byte) { 20 bufPool.Put(data) 21 }