From 2b4053c016ffb92e9e60ab01dd9789e749725fc0 Mon Sep 17 00:00:00 2001 From: cuiweixie Date: Sun, 11 Jan 2026 16:32:58 +0800 Subject: [PATCH] core/state: optimize map usage --- core/state/statedb.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/core/state/statedb.go b/core/state/statedb.go index fbfb02e8e4..2f57f178c3 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -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 // all together func (s *StateDB) markDelete(addr common.Address) { - if _, ok := s.mutations[addr]; !ok { - s.mutations[addr] = &mutation{} + v, ok := s.mutations[addr] + if !ok { + v = &mutation{} + s.mutations[addr] = v } - s.mutations[addr].applied = false - s.mutations[addr].typ = deletion + v.applied = false + v.typ = deletion } func (s *StateDB) markUpdate(addr common.Address) { - if _, ok := s.mutations[addr]; !ok { - s.mutations[addr] = &mutation{} + v, ok := s.mutations[addr] + if !ok { + v = &mutation{} + s.mutations[addr] = v } - s.mutations[addr].applied = false - s.mutations[addr].typ = update + v.applied = false + v.typ = update } // Witness retrieves the current state witness being collected.