mirror of https://github.com/restic/restic.git
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
|
@ -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 New Issue