From 41840220c3a1e3eaa410fcbe7df8580af3477646 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Thu, 15 Aug 2024 11:49:13 -0700 Subject: [PATCH] Optimize version handling in mergeWithChild --- ConflictSet.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index eed9c8a..3756d37 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -1623,7 +1623,7 @@ void mergeWithChild(Node *&self, WriteContext *tls, ConflictSet::Impl *impl, getSearchPathPrintable(child).c_str()); #endif - InternalVersionT childMaxVersion = maxVersion(child, impl); + InternalVersionT childMaxVersion = self3->childMaxVersion[0]; // Construct new partial key for child memmove(child->partialKey() + self3->partialKeyLen + 1, child->partialKey(), @@ -1637,10 +1637,7 @@ void mergeWithChild(Node *&self, WriteContext *tls, ConflictSet::Impl *impl, // Max versions are stored in the parent, so we need to update it now // that we have a new parent. - setMaxVersion(child, impl, childMaxVersion); - if (child->parent) { - rezero(child->parent, tls->zero); - } + setMaxVersion(child, impl, std::max(childMaxVersion, tls->zero)); getInTree(self, impl) = child; tls->release(self3); @@ -3728,6 +3725,7 @@ InternalVersionT exchangeMaxVersion(Node *n, InternalVersionT newMax) { } void setMaxVersion(Node *n, ConflictSet::Impl *impl, InternalVersionT newMax) { + assert(newMax >= InternalVersionT::zero); int index = n->parentsIndex; n = n->parent; if (n == nullptr) {