From d69c9f56ea96e333dbf2f5b4b4e63685147fbc72 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Mon, 22 Dec 2025 15:11:56 -0500 Subject: [PATCH] clusterlin: count chunk deps without loop (optimization) This small optimization avoids the need to loop over the parents of each transaction when initializing the dependency-counting structures inside GetLinearization(). --- src/cluster_linearize.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/cluster_linearize.h b/src/cluster_linearize.h index 57d6a7a6c4b..882b335fdb6 100644 --- a/src/cluster_linearize.h +++ b/src/cluster_linearize.h @@ -1291,10 +1291,8 @@ public: tx_deps[chl_idx] = chl_data.parents.Count(); auto chl_chunk_rep = chl_data.chunk_rep; chunk_reps.Set(chl_chunk_rep); - for (auto par_idx : chl_data.parents) { - auto par_chunk_rep = m_tx_data[par_idx].chunk_rep; - chunk_deps[chl_chunk_rep] += (par_chunk_rep != chl_chunk_rep); - } + const auto& chl_chunk_txn = m_tx_data[chl_chunk_rep].chunk_setinfo.transactions; + chunk_deps[chl_chunk_rep] += (chl_data.parents - chl_chunk_txn).Count(); } /** Function to compute the highest element of a chunk, by fallback_order. */ auto max_fallback_fn = [&](TxIdx chunk_rep) noexcept {