trie: avoid spawning goroutines for empty children (#32220)

This commit is contained in:
Ömer Faruk Irmak 2025-07-16 16:00:39 +03:00 committed by GitHub
parent e94123acc2
commit 61d7279e1f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -105,18 +105,18 @@ func (h *hasher) hashFullNodeChildren(n *fullNode) *fullNode {
var children [17]node
if h.parallel {
var wg sync.WaitGroup
wg.Add(16)
for i := 0; i < 16; i++ {
go func(i int) {
hasher := newHasher(false)
if child := n.Children[i]; child != nil {
if child := n.Children[i]; child != nil {
wg.Add(1)
go func(i int) {
hasher := newHasher(false)
children[i] = hasher.hash(child, false)
} else {
children[i] = nilValueNode
}
returnHasherToPool(hasher)
wg.Done()
}(i)
returnHasherToPool(hasher)
wg.Done()
}(i)
} else {
children[i] = nilValueNode
}
}
wg.Wait()
} else {