core/state: initialize maps with known size (#27222)

* core/state : fix map size avoid resizing

* core/state : fixed size
This commit is contained in:
ucwong 2023-05-08 00:59:14 -06:00 committed by GitHub
parent 604e215d1b
commit cc8d40c65f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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 {