mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core/state: minor optimization in state onleaf allocation
This commit is contained in:
parent
0c86a2c5a6
commit
3a34e93c6c
1 changed files with 3 additions and 1 deletions
|
|
@ -750,8 +750,10 @@ func (s *StateDB) Commit(deleteEmptyObjects bool) (common.Hash, error) {
|
||||||
if metrics.EnabledExpensive {
|
if metrics.EnabledExpensive {
|
||||||
defer func(start time.Time) { s.AccountCommits += time.Since(start) }(time.Now())
|
defer func(start time.Time) { s.AccountCommits += time.Since(start) }(time.Now())
|
||||||
}
|
}
|
||||||
|
// The onleaf func is called _serially_, so we can reuse the same account
|
||||||
|
// for unmarshalling every time.
|
||||||
|
var account Account
|
||||||
return s.trie.Commit(func(leaf []byte, parent common.Hash) error {
|
return s.trie.Commit(func(leaf []byte, parent common.Hash) error {
|
||||||
var account Account
|
|
||||||
if err := rlp.DecodeBytes(leaf, &account); err != nil {
|
if err := rlp.DecodeBytes(leaf, &account); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue