@@ -151,8 +151,9 @@ class Cluster
151151 /* * Process elements from the front of args that apply to this cluster, and append Refs for the
152152 * union of their descendants to output. */
153153 void GetDescendantRefs (const TxGraphImpl& graph, std::span<std::pair<Cluster*, DepGraphIndex>>& args, std::vector<TxGraph::Ref*>& output) noexcept ;
154- /* * Get a vector of Refs for all elements of this Cluster, in linearization order. */
155- std::vector<TxGraph::Ref*> GetClusterRefs (const TxGraphImpl& graph) noexcept ;
154+ /* * Populate range with refs for the transactions in this Cluster's linearization, from
155+ * position start_pos until start_pos+range.size()-1, inclusive. */
156+ void GetClusterRefs (TxGraphImpl& graph, std::span<TxGraph::Ref*> range, LinearizationIndex start_pos) noexcept ;
156157 /* * Get the individual transaction feerate of a Cluster element. */
157158 FeePerWeight GetIndividualFeerate (DepGraphIndex idx) noexcept ;
158159 /* * Modify the fee of a Cluster element. */
@@ -1632,17 +1633,16 @@ void Cluster::GetDescendantRefs(const TxGraphImpl& graph, std::span<std::pair<Cl
16321633 }
16331634}
16341635
1635- std::vector <TxGraph::Ref*> Cluster::GetClusterRefs ( const TxGraphImpl& graph ) noexcept
1636+ void Cluster::GetClusterRefs (TxGraphImpl& graph, std::span <TxGraph::Ref*> range, LinearizationIndex start_pos ) noexcept
16361637{
1637- std::vector<TxGraph::Ref*> ret;
1638- ret. reserve (m_linearization. size ());
1639- // Translate all transactions in the Cluster (in linearization order) to Refs.
1640- for ( auto idx : m_linearization) {
1641- const auto & entry = graph.m_entries [m_mapping[idx ]];
1638+ // Translate the transactions in the Cluster (in linearization order, starting at start_pos in
1639+ // the linearization) to Refs, and fill them in range.
1640+ for ( auto & ref : range) {
1641+ Assume (start_pos < m_linearization. size ());
1642+ const auto & entry = graph.m_entries [m_mapping[m_linearization[start_pos++] ]];
16421643 Assume (entry.m_ref != nullptr );
1643- ret. push_back ( entry.m_ref ) ;
1644+ ref = entry.m_ref ;
16441645 }
1645- return ret;
16461646}
16471647
16481648FeePerWeight Cluster::GetIndividualFeerate (DepGraphIndex idx) noexcept
@@ -1786,7 +1786,9 @@ std::vector<TxGraph::Ref*> TxGraphImpl::GetCluster(const Ref& arg, bool main_onl
17861786 if (cluster == nullptr ) return {};
17871787 // Make sure the Cluster has an acceptable quality level, and then dispatch to it.
17881788 MakeAcceptable (*cluster);
1789- return cluster->GetClusterRefs (*this );
1789+ std::vector<TxGraph::Ref*> ret (cluster->GetTxCount ());
1790+ cluster->GetClusterRefs (*this , ret, 0 );
1791+ return ret;
17901792}
17911793
17921794TxGraph::GraphIndex TxGraphImpl::GetTransactionCount (bool main_only) noexcept
0 commit comments