From 00ed30e6fcd8a1edd5465b79195c016572e6795d Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Wed, 26 Feb 2025 16:38:10 +0100 Subject: [PATCH] trie: reduce allocations in trie hasher --- trie/hasher.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/trie/hasher.go b/trie/hasher.go index 28f7f3d0c3..ac203458ce 100644 --- a/trie/hasher.go +++ b/trie/hasher.go @@ -148,7 +148,9 @@ func (h *hasher) shortnodeToHash(n *shortNode, force bool) node { if len(enc) < 32 && !force { return n // Nodes smaller than 32 bytes are stored inside their parent } - return h.hashData(enc) + var hn hashNode + h.hashDataTo(hn, enc) + return hn } // fullnodeToHash is used to create a hashNode from a fullNode, (which @@ -160,7 +162,9 @@ func (h *hasher) fullnodeToHash(n *fullNode, force bool) node { if len(enc) < 32 && !force { return n // Nodes smaller than 32 bytes are stored inside their parent } - return h.hashData(enc) + var hn hashNode + h.hashDataTo(hn, enc) + return hn } // encodedBytes returns the result of the last encoding operation on h.encbuf.