mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-02-19 03:04:27 -05:00
perf(trie): use Entry API to avoid empty Vec allocation in extend (#21645)
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
committed by
GitHub
parent
e523a76fb8
commit
bfe778ab51
@@ -465,7 +465,14 @@ impl DecodedMultiProofV2 {
|
||||
pub fn extend(&mut self, other: Self) {
|
||||
self.account_proofs.extend(other.account_proofs);
|
||||
for (hashed_address, other_storage_proofs) in other.storage_proofs {
|
||||
self.storage_proofs.entry(hashed_address).or_default().extend(other_storage_proofs);
|
||||
match self.storage_proofs.entry(hashed_address) {
|
||||
hash_map::Entry::Vacant(entry) => {
|
||||
entry.insert(other_storage_proofs);
|
||||
}
|
||||
hash_map::Entry::Occupied(mut entry) => {
|
||||
entry.get_mut().extend(other_storage_proofs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user