trie: cleaner array concatenation (#32756)
Some checks failed
/ Linux Build (push) Has been cancelled
/ Linux Build (arm) (push) Has been cancelled
/ Windows Build (push) Has been cancelled
/ Docker Image (push) Has been cancelled

It uses the slices.Concat and slices.Clone methods available now in Go.
This commit is contained in:
hero5512 2025-10-02 11:32:20 -04:00 committed by GitHub
parent 4927e89647
commit 1e4b39ed12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -19,6 +19,7 @@ package trie
import (
"errors"
"fmt"
"slices"
"sync"
"github.com/ethereum/go-ethereum/common"
@ -553,7 +554,7 @@ func (s *Sync) children(req *nodeRequest, object node) ([]*nodeRequest, error) {
}
children = []childNode{{
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**
// 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 {
children = append(children, childNode{
node: node.Children[i],
path: append(append([]byte(nil), req.path...), byte(i)),
path: append(slices.Clone(req.path), byte(i)),
})
}
}