snapshot: merge loops for better performance (#22160)

This commit is contained in:
Melvin Junhee Woo 2021-01-25 22:25:55 +09:00 committed by GitHub
parent 59a79137b9
commit 04a72260c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -191,19 +191,15 @@ func newDiffLayer(parent snapshot, root common.Hash, destructs map[common.Hash]s
if blob == nil { if blob == nil {
panic(fmt.Sprintf("account %#x nil", accountHash)) 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 { for accountHash, slots := range storage {
if slots == nil { if slots == nil {
panic(fmt.Sprintf("storage %#x nil", accountHash)) panic(fmt.Sprintf("storage %#x nil", accountHash))
} }
}
// Determine memory size and track the dirty writes // 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 {
for _, data := range slots { for _, data := range slots {
dl.memory += uint64(common.HashLength + len(data)) dl.memory += uint64(common.HashLength + len(data))
snapshotDirtyStorageWriteMeter.Mark(int64(len(data))) snapshotDirtyStorageWriteMeter.Mark(int64(len(data)))