Skip to content

Commit

Permalink
snapshot: merge loops for better performance (ethereum#22160)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehnuje authored Jan 25, 2021
1 parent 59a7913 commit 04a7226
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions core/state/snapshot/difflayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,15 @@ func newDiffLayer(parent snapshot, root common.Hash, destructs map[common.Hash]s
if blob == nil {
panic(fmt.Sprintf("account %#x nil", accountHash))
}
// Determine memory size and track the dirty writes
dl.memory += uint64(common.HashLength + len(blob))
snapshotDirtyAccountWriteMeter.Mark(int64(len(blob)))
}
for accountHash, slots := range storage {
if slots == nil {
panic(fmt.Sprintf("storage %#x nil", accountHash))
}
}
// Determine memory size and track the dirty writes
for _, data := range accounts {
dl.memory += uint64(common.HashLength + len(data))
snapshotDirtyAccountWriteMeter.Mark(int64(len(data)))
}
// Determine memory size and track the dirty writes
for _, slots := range storage {
// Determine memory size and track the dirty writes
for _, data := range slots {
dl.memory += uint64(common.HashLength + len(data))
snapshotDirtyStorageWriteMeter.Mark(int64(len(data)))
Expand Down

0 comments on commit 04a7226

Please sign in to comment.