Skip to content

Commit 1e4b39e

Browse files
authored
trie: cleaner array concatenation (#32756)
It uses the slices.Concat and slices.Clone methods available now in Go.
1 parent 4927e89 commit 1e4b39e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

trie/sync.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package trie
1919
import (
2020
"errors"
2121
"fmt"
22+
"slices"
2223
"sync"
2324

2425
"github.com/ethereum/go-ethereum/common"
@@ -553,7 +554,7 @@ func (s *Sync) children(req *nodeRequest, object node) ([]*nodeRequest, error) {
553554
}
554555
children = []childNode{{
555556
node: node.Val,
556-
path: append(append([]byte(nil), req.path...), key...),
557+
path: slices.Concat(req.path, key),
557558
}}
558559
// Mark all internal nodes between shortNode and its **in disk**
559560
// 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) {
595596
if node.Children[i] != nil {
596597
children = append(children, childNode{
597598
node: node.Children[i],
598-
path: append(append([]byte(nil), req.path...), byte(i)),
599+
path: append(slices.Clone(req.path), byte(i)),
599600
})
600601
}
601602
}

0 commit comments

Comments
 (0)