chunker: move buffer pool to chunker package

This commit is contained in:
Alexander Neumann
2015-05-05 00:45:29 +02:00
parent bdbb3ab329
commit ea22b2dfb1
4 changed files with 26 additions and 42 deletions

View File

@@ -170,12 +170,6 @@ func updateNodeContent(node *Node, results []saveResult) error {
return nil
}
const chunkerBufSize = 512 * chunker.KiB
var chunkerBufPool = sync.Pool{
New: func() interface{} { return make([]byte, chunkerBufSize) },
}
// SaveFile stores the content of the file on the backend as a Blob by calling
// Save for each chunk.
func (arch *Archiver) SaveFile(p *Progress, node *Node) error {
@@ -190,9 +184,7 @@ func (arch *Archiver) SaveFile(p *Progress, node *Node) error {
return err
}
buf := chunkerBufPool.Get().([]byte)
chnker := chunker.New(file, arch.s.Config.ChunkerPolynomial, buf, sha256.New())
defer chunkerBufPool.Put(buf)
chnker := chunker.New(file, arch.s.Config.ChunkerPolynomial, sha256.New())
resultChannels := [](<-chan saveResult){}
for {