From 477f04a798a6319c131a2dc373933111d435edf9 Mon Sep 17 00:00:00 2001 From: john xu Date: Wed, 22 Jan 2025 17:09:51 +0800 Subject: [PATCH] refactor(state): simplify key retrieval in TouchedAccounts using maps.Keys --- core/state/taiko_statedb.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/core/state/taiko_statedb.go b/core/state/taiko_statedb.go index 22cf68eb3063..68f05b14ceaf 100644 --- a/core/state/taiko_statedb.go +++ b/core/state/taiko_statedb.go @@ -2,16 +2,9 @@ package state import ( "github.com/ethereum/go-ethereum/common" + "golang.org/x/exp/maps" ) -func (s Storage) Keys() []common.Hash { - keys := make([]common.Hash, 0, len(s)) - for key := range s { - keys = append(keys, key) - } - return keys -} - // TouchedAccounts represents the storage of an account at a specific point in time. type TouchedAccounts map[common.Address][]common.Hash @@ -20,12 +13,12 @@ type TouchedAccounts map[common.Address][]common.Hash func (s *StateDB) TouchedAccounts() TouchedAccounts { touched := make(TouchedAccounts, len(s.stateObjects)) for addr, obj := range s.stateObjects { - touched[addr] = obj.originStorage.Keys() + touched[addr] = maps.Keys(obj.originStorage) } for addr, obj := range s.stateObjectsDestruct { // ignore empty account because it won't affect the state if !obj.empty() { - touched[addr] = obj.originStorage.Keys() + touched[addr] = maps.Keys(obj.originStorage) } } return touched