mirror of
https://github.com/octoleo/restic.git
synced 2024-11-29 16:23:59 +00:00
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
Block a user