clone map by maps.Clone

This commit is contained in:
maskpp 2024-06-13 01:47:24 +08:00
parent d294dd04d5
commit 3295f8aa82

View file

@ -19,6 +19,7 @@ package pathdb
import (
"bytes"
"fmt"
"maps"
"time"
"github.com/VictoriaMetrics/fastcache"
@ -90,12 +91,10 @@ func (b *nodebuffer) commit(nodes map[common.Hash]map[string]*trienode.Node) *no
// The nodes belong to original diff layer are still accessible even
// after merging, thus the ownership of nodes map should still belong
// to original layer and any mutation on it should be prevented.
current = make(map[string]*trienode.Node, len(subset))
for path, n := range subset {
current[path] = n
delta += int64(len(n.Blob) + len(path))
}
b.nodes[owner] = current
b.nodes[owner] = maps.Clone(subset)
continue
}
for path, n := range subset {