Make decryptReader fulfill flate.Reader

benchmark               old ns/op     new ns/op     delta
    BenchmarkLoadJSONID     50232171      48596972      -3.26%

    benchmark               old allocs     new allocs     delta
    BenchmarkLoadJSONID     43643          42884          -1.74%

    benchmark               old bytes     new bytes     delta
    BenchmarkLoadJSONID     5773048       3785517       -34.43%
This commit is contained in:
Alexander Neumann 2015-02-18 23:30:59 +01:00
parent a0fea201d9
commit 2f3aa344af
2 changed files with 22 additions and 1 deletions

View file

@ -2,6 +2,7 @@ package restic
import (
"bytes"
"compress/flate"
"compress/zlib"
"crypto/sha256"
"encoding/json"
@ -146,8 +147,10 @@ func (s Server) LoadJSONID(t backend.Type, storageID backend.ID, item interface{
}
// unzip
br := decryptRd.(flate.Reader)
unzipRd := zReaderPool.Get().(zReader)
err = unzipRd.Reset(decryptRd, nil)
err = unzipRd.Reset(br, nil)
defer func() {
unzipRd.Close()
zReaderPool.Put(unzipRd)