From bfe778ab5157d9b553a56d8c60cf1d2586d395b8 Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Fri, 30 Jan 2026 14:29:21 -0800 Subject: [PATCH] perf(trie): use Entry API to avoid empty Vec allocation in extend (#21645) Co-authored-by: Amp --- crates/trie/common/src/proofs.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/trie/common/src/proofs.rs b/crates/trie/common/src/proofs.rs index b65b3ec966..c782a075d9 100644 --- a/crates/trie/common/src/proofs.rs +++ b/crates/trie/common/src/proofs.rs @@ -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); + } + } } } }