From dcf67c04a45944d77ff89ae95c863e9a64313939 Mon Sep 17 00:00:00 2001 From: MariusVanDerWijden Date: Tue, 2 Jun 2026 16:38:14 +0200 Subject: [PATCH] trie: cleanup --- trie/committer.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/trie/committer.go b/trie/committer.go index 11799be74b..590ebbb648 100644 --- a/trie/committer.go +++ b/trie/committer.go @@ -87,9 +87,7 @@ func (c *committer) commit(path []byte, n node, parallel bool) node { // commitChildren commits the children of the given fullnode func (c *committer) commitChildren(path []byte, n *fullNode, parallel bool) { - var ( - index = make([]int, 0, 16) - ) + childIndices := make([]int, 0, 16) for i := 0; i < 16; i++ { child := n.Children[i] if child == nil { @@ -101,13 +99,13 @@ func (c *committer) commitChildren(path []byte, n *fullNode, parallel bool) { if _, ok := child.(hashNode); ok { continue } - index = append(index, i) + childIndices = append(childIndices, i) } if !parallel { // Commit the child recursively and store the "hashed" value. // Note the returned node can be some embedded nodes, so it's // possible the type is not hashNode. - for _, i := range index { + for _, i := range childIndices { n.Children[i] = c.commit(append(path, byte(i)), n.Children[i], false) } } else { @@ -115,15 +113,15 @@ func (c *committer) commitChildren(path []byte, n *fullNode, parallel bool) { wg sync.WaitGroup nodesMu sync.Mutex ) - wg.Add(len(index)) - for _, i := range index { + wg.Add(len(childIndices)) + for _, i := range childIndices { go func(index int) { defer wg.Done() p := append(path, byte(index)) childSet := trienode.NewNodeSet(c.nodes.Owner) childCommitter := newCommitter(childSet, c.tracer, c.collectLeaf) - n.Children[index] = childCommitter.commit(p, n.Children[i], false) + n.Children[index] = childCommitter.commit(p, n.Children[index], false) nodesMu.Lock() c.nodes.MergeDisjoint(childSet)