mirror of
https://github.com/octoleo/restic.git
synced 2024-11-26 06:46:34 +00:00
Speed up blob sorting in internal/repository
name old time/op new time/op delta SortCachedPacksFirst-8 208µs ± 3% 186µs ± 3% -10.74% (p=0.000 n=10+8) name old alloc/op new alloc/op delta SortCachedPacksFirst-8 213kB ± 0% 139kB ± 0% -34.62% (p=0.000 n=10+10) name old allocs/op new allocs/op delta SortCachedPacksFirst-8 1.03k ± 0% 1.03k ± 0% -0.19% (p=0.000 n=10+10)
This commit is contained in:
parent
b10acd2af7
commit
03d23e6faa
@ -116,6 +116,7 @@ type haver interface {
|
||||
}
|
||||
|
||||
// sortCachedPacksFirst moves all cached pack files to the front of blobs.
|
||||
// It overwrites blobs.
|
||||
func sortCachedPacksFirst(cache haver, blobs []restic.PackedBlob) []restic.PackedBlob {
|
||||
if cache == nil {
|
||||
return blobs
|
||||
@ -126,7 +127,7 @@ func sortCachedPacksFirst(cache haver, blobs []restic.PackedBlob) []restic.Packe
|
||||
return blobs
|
||||
}
|
||||
|
||||
cached := make([]restic.PackedBlob, 0, len(blobs)/2)
|
||||
cached := blobs[:0]
|
||||
noncached := make([]restic.PackedBlob, 0, len(blobs)/2)
|
||||
|
||||
for _, blob := range blobs {
|
||||
|
Loading…
Reference in New Issue
Block a user