From f9484669760e53015b265e0c12ef411b6245a678 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Fri, 29 Nov 2024 16:08:31 +0800 Subject: [PATCH] crypto: less allocations when hashing and tx handling (#21265) --- crypto/crypto.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crypto/crypto.go b/crypto/crypto.go index 22849aa6ea..29d2b75ecd 100644 --- a/crypto/crypto.go +++ b/crypto/crypto.go @@ -75,7 +75,7 @@ func HashData(kh KeccakState, data []byte) (h common.Hash) { // Keccak256 calculates and returns the Keccak256 hash of the input data. func Keccak256(data ...[]byte) []byte { b := make([]byte, 32) - d := NewKeccakState() + d := sha3.NewLegacyKeccak256().(KeccakState) for _, b := range data { d.Write(b) } @@ -86,7 +86,7 @@ func Keccak256(data ...[]byte) []byte { // Keccak256Hash calculates and returns the Keccak256 hash of the input data, // converting it to an internal Hash data structure. func Keccak256Hash(data ...[]byte) (h common.Hash) { - d := NewKeccakState() + d := sha3.NewLegacyKeccak256().(KeccakState) for _, b := range data { d.Write(b) }