Update test_hash.go

This commit is contained in:
alex017 2025-12-18 21:15:53 +01:00 committed by GitHub
parent bd77b77ede
commit 4773a557b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -23,7 +23,6 @@
package blocktest package blocktest
import ( import (
"bytes"
"hash" "hash"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
@ -49,8 +48,9 @@ func (h *testHasher) Reset() {
// Update updates the hash state with the given key and value. // Update updates the hash state with the given key and value.
func (h *testHasher) Update(key, val []byte) error { func (h *testHasher) Update(key, val []byte) error {
h.hasher.Write(bytes.Clone(key)) // The hasher copies input data, so avoid redundant Clone allocations.
h.hasher.Write(bytes.Clone(val)) h.hasher.Write(key)
h.hasher.Write(val)
return nil return nil
} }