Skip to content

Commit

Permalink
trie: avoid un-needed map copy (ethereum#30343)
Browse files Browse the repository at this point in the history
This change avoids the an unnecessary map copy if the preimage recording is not enabled.
  • Loading branch information
rjl493456442 authored and zfy0701 committed Dec 3, 2024
1 parent 664e106 commit 2299270
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions trie/secure_trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,11 @@ func (t *StateTrie) Witness() map[string]struct{} {
func (t *StateTrie) Commit(collectLeaf bool) (common.Hash, *trienode.NodeSet) {
// Write all the pre-images to the actual disk database
if len(t.getSecKeyCache()) > 0 {
preimages := make(map[common.Hash][]byte, len(t.secKeyCache))
for hk, key := range t.secKeyCache {
preimages[common.BytesToHash([]byte(hk))] = key
}
if t.preimages != nil {
preimages := make(map[common.Hash][]byte, len(t.secKeyCache))
for hk, key := range t.secKeyCache {
preimages[common.BytesToHash([]byte(hk))] = key
}
t.preimages.InsertPreimage(preimages)
}
t.secKeyCache = make(map[string][]byte)
Expand Down

0 comments on commit 2299270

Please sign in to comment.