Skip to content

Commit c99c730

Browse files
committed
txgraph: Abstract out ClearLocator (refactor)
Move a number of related modifications to TxGraphImpl into a separate function for removal of transactions. This is preparation for a later commit where this will be useful in more than one place.
1 parent 34aa3da commit c99c730

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/txgraph.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ class TxGraphImpl final : public TxGraph
274274
ClusterSetIndex InsertCluster(std::unique_ptr<Cluster>&& cluster, QualityLevel quality) noexcept;
275275
/** Change the QualityLevel of a Cluster (identified by old_quality and old_index). */
276276
void SetClusterQuality(QualityLevel old_quality, ClusterSetIndex old_index, QualityLevel new_quality) noexcept;
277+
/** Make a transaction not exist. It must currently exist. */
278+
void ClearLocator(GraphIndex index) noexcept;
277279

278280
// Functions for handling Refs.
279281

@@ -335,6 +337,16 @@ class TxGraphImpl final : public TxGraph
335337
void SanityCheck() const final;
336338
};
337339

340+
void TxGraphImpl::ClearLocator(GraphIndex idx) noexcept
341+
{
342+
auto& entry = m_entries[idx];
343+
Assume(entry.m_locator.IsPresent());
344+
// Change the locator from Present to Missing.
345+
entry.m_locator.SetMissing();
346+
// Update the transaction count.
347+
--m_clusterset.m_txcount;
348+
}
349+
338350
void Cluster::Updated(TxGraphImpl& graph) noexcept
339351
{
340352
// Update all the Locators for this Cluster's Entrys.
@@ -385,9 +397,8 @@ void Cluster::ApplyRemovals(TxGraphImpl& graph, std::span<GraphIndex>& to_remove
385397
// that causes it to be accessed regardless.
386398
m_mapping[locator.index] = GraphIndex(-1);
387399
// - Mark it as removed in the Entry's locator.
388-
locator.SetMissing();
400+
graph.ClearLocator(idx);
389401
to_remove = to_remove.subspan(1);
390-
--graph.m_clusterset.m_txcount;
391402
} while(!to_remove.empty());
392403

393404
auto quality = m_quality;

0 commit comments

Comments
 (0)