From 63740b7aca732f6c204c56a9e4b4932f5251e4e0 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Tue, 20 May 2025 18:31:01 +0200 Subject: [PATCH] core/state: reduce allocation in updateStateObject (#31861) Optimize updateStateObject to reduce an allocation. --- core/state/statedb.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/state/statedb.go b/core/state/statedb.go index 2453d67f3e..51453055c3 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -562,9 +562,8 @@ func (s *StateDB) GetTransientState(addr common.Address, key common.Hash) common // updateStateObject writes the given object to the trie. func (s *StateDB) updateStateObject(obj *stateObject) { // Encode the account and update the account trie - addr := obj.Address() - if err := s.trie.UpdateAccount(addr, &obj.data, len(obj.code)); err != nil { - s.setError(fmt.Errorf("updateStateObject (%x) error: %v", addr[:], err)) + if err := s.trie.UpdateAccount(obj.Address(), &obj.data, len(obj.code)); err != nil { + s.setError(fmt.Errorf("updateStateObject (%x) error: %v", obj.Address(), err)) } if obj.dirtyCode { s.trie.UpdateContractCode(obj.Address(), common.BytesToHash(obj.CodeHash()), obj.code)