Improve comments and asserts

This commit is contained in:
2024-01-21 14:30:09 -08:00
parent 9855e64b6a
commit 4459c3cb87

View File

@@ -518,7 +518,7 @@ struct Iterator {
};
// Call Stepwise::step for each element of remaining until it returns true.
// Applies a permutation to remaining as a side effect.
// Applies a permutation to `remaining` as a side effect.
template <class Stepwise>
void runInterleaved(std::span<Stepwise> remaining, int stepLimit = -1) {
while (remaining.size() > 0) {
@@ -939,7 +939,7 @@ struct __attribute__((__visibility__("hidden"))) ConflictSet::Impl {
}
struct StepwiseInsert {
// After this phase, the heap invariant may be violated for
// After this phase, the heap invariant may be violated for *current and
// (*current)->parent.
Node **current;
Node *parent;
@@ -964,6 +964,7 @@ struct __attribute__((__visibility__("hidden"))) ConflictSet::Impl {
// We could interleave the iteration in ::next, but we'd need a careful
// analysis for correctness and it's unlikely to be worthwhile.
auto *prev = ::next(newNode, false);
// The empty key always exists. If *key is empty then we won't reach here.
assert(prev != nullptr);
assert(prev->rangeVersion <= writeVersion);
newNode->rangeVersion = prev->rangeVersion;
@@ -1010,6 +1011,8 @@ struct __attribute__((__visibility__("hidden"))) ConflictSet::Impl {
ArenaAlloc<Node *>(&arena)};
workList.reserve(count);
for (int i = 0; i < count; ++i) {
Node *node = *stepwiseInserts[i].current;
assert(node != nullptr);
workList.push_back(*stepwiseInserts[i].current);
}