mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-30 03:01:58 -04:00
perf(trie): reserve capacity in apply_subtrie_update_actions (#22517)
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
committed by
GitHub
parent
56bb47709c
commit
d1cbf6ca5a
@@ -999,6 +999,7 @@ impl SparseTrie for ParallelSparseTrie {
|
||||
// Sync branch_node_masks with what's being committed to DB.
|
||||
// This ensures that on subsequent root() calls, the masks reflect the actual
|
||||
// DB state, which is needed for correct removal detection.
|
||||
self.branch_node_masks.reserve(updates.updated_nodes.len());
|
||||
for (path, node) in &updates.updated_nodes {
|
||||
self.branch_node_masks.insert(
|
||||
*path,
|
||||
@@ -1854,6 +1855,9 @@ impl ParallelSparseTrie {
|
||||
update_actions: impl Iterator<Item = SparseTrieUpdatesAction>,
|
||||
) {
|
||||
if let Some(updates) = self.updates.as_mut() {
|
||||
let additional = update_actions.size_hint().0;
|
||||
updates.updated_nodes.reserve(additional);
|
||||
updates.removed_nodes.reserve(additional);
|
||||
for action in update_actions {
|
||||
match action {
|
||||
SparseTrieUpdatesAction::InsertRemoved(path) => {
|
||||
|
||||
Reference in New Issue
Block a user