Skip to content

Commit

Permalink
trie: preallocate capacity for fields slice (ethereum#29614)
Browse files Browse the repository at this point in the history
trie: Preallocate capacity for fields slice
  • Loading branch information
qcrao authored and stwiname committed Sep 9, 2024
1 parent d95ca55 commit b29bf18
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions trie/trienode/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func NewNodeSet(owner common.Hash) *NodeSet {
// ForEachWithOrder iterates the nodes with the order from bottom to top,
// right to left, nodes with the longest path will be iterated first.
func (set *NodeSet) ForEachWithOrder(callback func(path string, n *Node)) {
var paths []string
paths := make([]string, 0, len(set.Nodes))
for path := range set.Nodes {
paths = append(paths, path)
}
Expand Down Expand Up @@ -133,7 +133,7 @@ func (set *NodeSet) Size() (int, int) {
// Hashes returns the hashes of all updated nodes. TODO(rjl493456442) how can
// we get rid of it?
func (set *NodeSet) Hashes() []common.Hash {
var ret []common.Hash
ret := make([]common.Hash, 0, len(set.Nodes))
for _, node := range set.Nodes {
ret = append(ret, node.Hash)
}
Expand Down

0 comments on commit b29bf18

Please sign in to comment.