mirror of
https://github.com/restic/restic.git
synced 2024-12-25 09:18:55 +00:00
Leave allocating slices to the decompress code
This commit is contained in:
parent
5eb05a0afe
commit
8776031f96
1 changed files with 2 additions and 3 deletions
|
@ -1021,9 +1021,8 @@ func StreamPack(ctx context.Context, beLoad BackendLoadFn, key *crypto.Key, pack
|
|||
nonce, ciphertext := buf[:key.NonceSize()], buf[key.NonceSize():]
|
||||
plaintext, err := key.Open(ciphertext[:0], nonce, ciphertext, nil)
|
||||
if err == nil && entry.IsCompressed() {
|
||||
if cap(decode) < int(entry.DataLength()) {
|
||||
decode = make([]byte, 0, entry.DataLength())
|
||||
}
|
||||
// DecodeAll will allocate a slice if it is not large enough since it
|
||||
// knows the decompressed size (because we're using EncodeAll)
|
||||
decode, err = dec.DecodeAll(plaintext, decode[:0])
|
||||
plaintext = decode
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue