Unverified Commit cc8d40c6 authored by ucwong's avatar ucwong Committed by GitHub

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

* core/state : fix map size avoid resizing

* core/state : fixed size
parent 604e215d
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment