mirror of
https://github.com/restic/restic.git
synced 2025-10-10 11:32:17 +00:00
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:
@@ -550,12 +550,13 @@ func (arch *Archiver) statDir(dir string) (os.FileInfo, error) {
|
||||
func (arch *Archiver) SaveTree(ctx context.Context, snPath string, atree *Tree, previous *restic.Tree) (*restic.Tree, error) {
|
||||
debug.Log("%v (%v nodes), parent %v", snPath, len(atree.Nodes), previous)
|
||||
|
||||
tree := restic.NewTree()
|
||||
nodeNames := atree.NodeNames()
|
||||
tree := restic.NewTree(len(nodeNames))
|
||||
|
||||
futureNodes := make(map[string]FutureNode)
|
||||
|
||||
// iterate over the nodes of atree in lexicographic (=deterministic) order
|
||||
for _, name := range atree.NodeNames() {
|
||||
for _, name := range nodeNames {
|
||||
subatree := atree.Nodes[name]
|
||||
|
||||
// test if context has been cancelled
|
||||
|
Reference in New Issue
Block a user