Skip to content

Commit 04a7226

Browse files
authored
snapshot: merge loops for better performance (ethereum#22160)
1 parent 59a7913 commit 04a7226

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

core/state/snapshot/difflayer.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,19 +191,15 @@ func newDiffLayer(parent snapshot, root common.Hash, destructs map[common.Hash]s
191191
if blob == nil {
192192
panic(fmt.Sprintf("account %#x nil", accountHash))
193193
}
194+
// Determine memory size and track the dirty writes
195+
dl.memory += uint64(common.HashLength + len(blob))
196+
snapshotDirtyAccountWriteMeter.Mark(int64(len(blob)))
194197
}
195198
for accountHash, slots := range storage {
196199
if slots == nil {
197200
panic(fmt.Sprintf("storage %#x nil", accountHash))
198201
}
199-
}
200-
// Determine memory size and track the dirty writes
201-
for _, data := range accounts {
202-
dl.memory += uint64(common.HashLength + len(data))
203-
snapshotDirtyAccountWriteMeter.Mark(int64(len(data)))
204-
}
205-
// Determine memory size and track the dirty writes
206-
for _, slots := range storage {
202+
// Determine memory size and track the dirty writes
207203
for _, data := range slots {
208204
dl.memory += uint64(common.HashLength + len(data))
209205
snapshotDirtyStorageWriteMeter.Mark(int64(len(data)))

0 commit comments

Comments
 (0)