mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
trie: optimize array allocation during sync path construction
This commit is contained in:
parent
8e87b7539b
commit
15f6d24a9b
1 changed files with 8 additions and 2 deletions
10
trie/sync.go
10
trie/sync.go
|
|
@ -551,9 +551,12 @@ func (s *Sync) children(req *nodeRequest, object node) ([]*nodeRequest, error) {
|
||||||
if hasTerm(key) {
|
if hasTerm(key) {
|
||||||
key = key[:len(key)-1]
|
key = key[:len(key)-1]
|
||||||
}
|
}
|
||||||
|
path := make([]byte, len(req.path)+len(key))
|
||||||
|
copy(path, req.path)
|
||||||
|
copy(path[len(req.path):], key)
|
||||||
children = []childNode{{
|
children = []childNode{{
|
||||||
node: node.Val,
|
node: node.Val,
|
||||||
path: append(append([]byte(nil), req.path...), key...),
|
path: path,
|
||||||
}}
|
}}
|
||||||
// Mark all internal nodes between shortNode and its **in disk**
|
// Mark all internal nodes between shortNode and its **in disk**
|
||||||
// child as invalid. This is essential in the case of path mode
|
// child as invalid. This is essential in the case of path mode
|
||||||
|
|
@ -593,9 +596,12 @@ func (s *Sync) children(req *nodeRequest, object node) ([]*nodeRequest, error) {
|
||||||
case *fullNode:
|
case *fullNode:
|
||||||
for i := 0; i < 17; i++ {
|
for i := 0; i < 17; i++ {
|
||||||
if node.Children[i] != nil {
|
if node.Children[i] != nil {
|
||||||
|
path := make([]byte, len(req.path)+1)
|
||||||
|
copy(path, req.path)
|
||||||
|
path[len(req.path)] = byte(i)
|
||||||
children = append(children, childNode{
|
children = append(children, childNode{
|
||||||
node: node.Children[i],
|
node: node.Children[i],
|
||||||
path: append(append([]byte(nil), req.path...), byte(i)),
|
path: path,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue