From 1df4eb14d68d3e8bb9f1f14f2ee2f47e43c32134 Mon Sep 17 00:00:00 2001 From: maskpp Date: Mon, 19 May 2025 00:00:18 +0800 Subject: [PATCH] decrease the creation of hasher --- trie/hasher.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/trie/hasher.go b/trie/hasher.go index 393cb0bd4d..16606808c9 100644 --- a/trie/hasher.go +++ b/trie/hasher.go @@ -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 {