use slices.Concat to replace append(nil)

This commit is contained in:
Matt D 2025-05-04 05:59:57 +05:00 committed by GitHub
parent 8868ad6d6e
commit c4aee35373
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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.Concat(req.path), byte(i)),
}) })
} }
} }