diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 4f1790d..513e2b4 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -1747,6 +1747,7 @@ void maybeDownsize(Node *self, WriteContext *tls, ConflictSet::Impl *impl, // path to self. May invalidate children of self->parent. Returns a pointer to // the node after self. If erase invalidates the pointee of `dontInvalidate`, it // will update it to its new pointee as well. Precondition: `self->entryPresent` +template Node *erase(Node *self, WriteContext *tls, ConflictSet::Impl *impl, bool logical, Node *&dontInvalidate) { ++tls->accum.entries_erased; @@ -1768,8 +1769,10 @@ Node *erase(Node *self, WriteContext *tls, ConflictSet::Impl *impl, if (self->numChildren != 0) { const bool update = result == dontInvalidate; maybeDownsize(self, tls, impl, result); - if (update) { - dontInvalidate = result; + if constexpr (kCheckDontInvalidate) { + if (update) { + dontInvalidate = result; + } } return result; } @@ -1852,13 +1855,21 @@ Node *erase(Node *self, WriteContext *tls, ConflictSet::Impl *impl, const bool update = result == dontInvalidate; maybeDownsize(parent, tls, impl, result); - if (update) { - dontInvalidate = result; + if constexpr (kCheckDontInvalidate) { + if (update) { + dontInvalidate = result; + } } return result; } +Node *erase(Node *self, WriteContext *tls, ConflictSet::Impl *impl, + bool logical) { + Node *dummy; + return erase(self, tls, impl, logical, dummy); +} + Node *nextSibling(Node *node) { for (;;) { if (node->parent == nullptr) { @@ -3262,8 +3273,7 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl { // There's no way to insert a range such that range version of the right // node is greater than the point version of the left node assert(n->entry.rangeVersion <= oldestVersion); - Node *dummy = nullptr; - n = erase(n, &tls, this, /*logical*/ false, dummy); + n = erase(n, &tls, this, /*logical*/ false); } else { maybeDecreaseCapacity(n, &tls, this); n = nextPhysical(n);