mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-02-19 03:04:27 -05:00
perf(trie): use HashMap reserve heuristic in MultiProof::extend (#21199)
This commit is contained in:
@@ -267,6 +267,12 @@ impl MultiProof {
|
||||
self.account_subtree.extend_from(other.account_subtree);
|
||||
self.branch_node_masks.extend(other.branch_node_masks);
|
||||
|
||||
let reserve = if self.storages.is_empty() {
|
||||
other.storages.len()
|
||||
} else {
|
||||
other.storages.len().div_ceil(2)
|
||||
};
|
||||
self.storages.reserve(reserve);
|
||||
for (hashed_address, storage) in other.storages {
|
||||
match self.storages.entry(hashed_address) {
|
||||
hash_map::Entry::Occupied(mut entry) => {
|
||||
@@ -390,6 +396,12 @@ impl DecodedMultiProof {
|
||||
self.account_subtree.extend_from(other.account_subtree);
|
||||
self.branch_node_masks.extend(other.branch_node_masks);
|
||||
|
||||
let reserve = if self.storages.is_empty() {
|
||||
other.storages.len()
|
||||
} else {
|
||||
other.storages.len().div_ceil(2)
|
||||
};
|
||||
self.storages.reserve(reserve);
|
||||
for (hashed_address, storage) in other.storages {
|
||||
match self.storages.entry(hashed_address) {
|
||||
hash_map::Entry::Occupied(mut entry) => {
|
||||
|
||||
Reference in New Issue
Block a user