diff --git a/core/state/statedb.go b/core/state/statedb.go index b89f4bfd8..a4e22baaf 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -783,13 +783,13 @@ func (s *StateDB) Copy() *StateDB { state.snap = s.snap // deep copy needed - state.snapAccounts = make(map[common.Hash][]byte) + state.snapAccounts = make(map[common.Hash][]byte, len(s.snapAccounts)) for k, v := range s.snapAccounts { state.snapAccounts[k] = v } - state.snapStorage = make(map[common.Hash]map[common.Hash][]byte) + state.snapStorage = make(map[common.Hash]map[common.Hash][]byte, len(s.snapStorage)) for k, v := range s.snapStorage { - temp := make(map[common.Hash][]byte) + temp := make(map[common.Hash][]byte, len(v)) for kk, vv := range v { temp[kk] = vv } @@ -1160,7 +1160,7 @@ func (s *StateDB) SlotInAccessList(addr common.Address, slot common.Hash) (addre // convertAccountSet converts a provided account set from address keyed to hash keyed. func (s *StateDB) convertAccountSet(set map[common.Address]struct{}) map[common.Hash]struct{} { - ret := make(map[common.Hash]struct{}) + ret := make(map[common.Hash]struct{}, len(set)) for addr := range set { obj, exist := s.stateObjects[addr] if !exist {