internal/restic: Don't allocate in Tree.Insert

name         old time/op    new time/op    delta
BuildTree-8    34.6µs ± 4%     7.0µs ± 3%  -79.68%  (p=0.000 n=18+19)

name         old alloc/op   new alloc/op   delta
BuildTree-8    34.0kB ± 0%     0.9kB ± 0%  -97.37%  (p=0.000 n=20+20)

name         old allocs/op  new allocs/op  delta
BuildTree-8       108 ± 0%         1 ± 0%  -99.07%  (p=0.000 n=20+20)
This commit is contained in:
greatroar
2021-09-26 18:08:48 +02:00
parent 78dac2fd48
commit c892c0bab9
6 changed files with 35 additions and 11 deletions
+1 -1
View File
@@ -107,7 +107,7 @@ func runRecover(gopts GlobalOptions) error {
return nil
}
tree := restic.NewTree()
tree := restic.NewTree(len(roots))
for id := range roots {
var subtreeID = id
node := restic.Node{