core/state: optimize map usage

This commit is contained in:
cuiweixie 2026-01-11 16:32:58 +08:00
parent 127d1f42bb
commit 2b4053c016

View file

@ -1479,19 +1479,23 @@ func (s *StateDB) SlotInAccessList(addr common.Address, slot common.Hash) (addre
// not yet committed. The pending mutation is cached and will be applied // not yet committed. The pending mutation is cached and will be applied
// all together // all together
func (s *StateDB) markDelete(addr common.Address) { func (s *StateDB) markDelete(addr common.Address) {
if _, ok := s.mutations[addr]; !ok { v, ok := s.mutations[addr]
s.mutations[addr] = &mutation{} if !ok {
v = &mutation{}
s.mutations[addr] = v
} }
s.mutations[addr].applied = false v.applied = false
s.mutations[addr].typ = deletion v.typ = deletion
} }
func (s *StateDB) markUpdate(addr common.Address) { func (s *StateDB) markUpdate(addr common.Address) {
if _, ok := s.mutations[addr]; !ok { v, ok := s.mutations[addr]
s.mutations[addr] = &mutation{} if !ok {
v = &mutation{}
s.mutations[addr] = v
} }
s.mutations[addr].applied = false v.applied = false
s.mutations[addr].typ = update v.typ = update
} }
// Witness retrieves the current state witness being collected. // Witness retrieves the current state witness being collected.