Skip to content

Commit 43b2aac

Browse files
authored
trie: refactor to use slices.Concat (#32401)
1 parent 2e9c9b5 commit 43b2aac

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

trie/trie.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"bytes"
2222
"errors"
2323
"fmt"
24+
"slices"
2425

2526
"github.com/ethereum/go-ethereum/common"
2627
"github.com/ethereum/go-ethereum/core/types"
@@ -471,7 +472,7 @@ func (t *Trie) delete(n node, prefix, key []byte) (bool, node, error) {
471472
// always creates a new slice) instead of append to
472473
// avoid modifying n.Key since it might be shared with
473474
// other nodes.
474-
return true, &shortNode{concat(n.Key, child.Key...), child.Val, t.newFlag()}, nil
475+
return true, &shortNode{slices.Concat(n.Key, child.Key), child.Val, t.newFlag()}, nil
475476
default:
476477
return true, &shortNode{n.Key, child, t.newFlag()}, nil
477478
}
@@ -566,13 +567,6 @@ func (t *Trie) delete(n node, prefix, key []byte) (bool, node, error) {
566567
}
567568
}
568569

569-
func concat(s1 []byte, s2 ...byte) []byte {
570-
r := make([]byte, len(s1)+len(s2))
571-
copy(r, s1)
572-
copy(r[len(s1):], s2)
573-
return r
574-
}
575-
576570
// copyNode deep-copies the supplied node along with its children recursively.
577571
func copyNode(n node) node {
578572
switch n := (n).(type) {

0 commit comments

Comments
 (0)