forked from TrueCloudLab/restic
prune: Reduce memory allocations while repacking
The slicing operator `slice[low:high]` default to 0 for the lower bound and len(slice) for the upper bound when either or both are not specified. Fix the code to use `cap(slice)` to check for the slice capacity.
This commit is contained in:
parent
7042bafea5
commit
367449dede
1 changed files with 1 additions and 2 deletions
|
@ -57,8 +57,7 @@ func Repack(ctx context.Context, repo restic.Repository, packs restic.IDSet, kee
|
|||
|
||||
debug.Log(" process blob %v", h)
|
||||
|
||||
buf = buf[:]
|
||||
if uint(len(buf)) < entry.Length {
|
||||
if uint(cap(buf)) < entry.Length {
|
||||
buf = make([]byte, entry.Length)
|
||||
}
|
||||
buf = buf[:entry.Length]
|
||||
|
|
Loading…
Reference in a new issue