mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-14 20:16:36 +00:00
trie: cleaner array concatenation (#32756)
It uses the slices.Concat and slices.Clone methods available now in Go.
This commit is contained in:
parent
4927e89647
commit
1e4b39ed12
1 changed files with 3 additions and 2 deletions
|
|
@ -19,6 +19,7 @@ package trie
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"slices"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
|
@ -553,7 +554,7 @@ func (s *Sync) children(req *nodeRequest, object node) ([]*nodeRequest, error) {
|
||||||
}
|
}
|
||||||
children = []childNode{{
|
children = []childNode{{
|
||||||
node: node.Val,
|
node: node.Val,
|
||||||
path: append(append([]byte(nil), req.path...), key...),
|
path: slices.Concat(req.path, key),
|
||||||
}}
|
}}
|
||||||
// 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
|
||||||
|
|
@ -595,7 +596,7 @@ func (s *Sync) children(req *nodeRequest, object node) ([]*nodeRequest, error) {
|
||||||
if node.Children[i] != nil {
|
if node.Children[i] != nil {
|
||||||
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: append(slices.Clone(req.path), byte(i)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue