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():]
|
nonce, ciphertext := buf[:key.NonceSize()], buf[key.NonceSize():]
|
||||||
plaintext, err := key.Open(ciphertext[:0], nonce, ciphertext, nil)
|
plaintext, err := key.Open(ciphertext[:0], nonce, ciphertext, nil)
|
||||||
if err == nil && entry.IsCompressed() {
|
if err == nil && entry.IsCompressed() {
|
||||||
if cap(decode) < int(entry.DataLength()) {
|
// DecodeAll will allocate a slice if it is not large enough since it
|
||||||
decode = make([]byte, 0, entry.DataLength())
|
// knows the decompressed size (because we're using EncodeAll)
|
||||||
}
|
|
||||||
decode, err = dec.DecodeAll(plaintext, decode[:0])
|
decode, err = dec.DecodeAll(plaintext, decode[:0])
|
||||||
plaintext = decode
|
plaintext = decode
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue