From 1c9dda68a62eac7feeca2222b8299119dd2432a1 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Mon, 12 Aug 2024 16:24:05 -0700 Subject: [PATCH] Call consumePartialKey from getOrCreateChild --- ConflictSet.cpp | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 13bb91c..a690e6e 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -1189,9 +1189,8 @@ Node *&getOrCreateChild(Node *&self, std::span &key, auto *self3 = static_cast(self); int i = getNodeIndex(self3, index); if (i >= 0) { - if (self3->children[i]->partialKeyLen == 0) { - self3->childMaxVersion[i] = newMaxVersion; - } + consumePartialKey(self3->children[i], key, newMaxVersion, tls); + self3->childMaxVersion[i] = newMaxVersion; return self3->children[i]; } } break; @@ -1199,9 +1198,8 @@ Node *&getOrCreateChild(Node *&self, std::span &key, auto *self16 = static_cast(self); int i = getNodeIndex(self16, index); if (i >= 0) { - if (self16->children[i]->partialKeyLen == 0) { - self16->childMaxVersion[i] = newMaxVersion; - } + consumePartialKey(self16->children[i], key, newMaxVersion, tls); + self16->childMaxVersion[i] = newMaxVersion; return self16->children[i]; } } break; @@ -1209,23 +1207,21 @@ Node *&getOrCreateChild(Node *&self, std::span &key, auto *self48 = static_cast(self); int secondIndex = self48->index[index]; if (secondIndex >= 0) { - if (self48->children[secondIndex]->partialKeyLen == 0) { - self48->childMaxVersion[secondIndex] = newMaxVersion; - self48->maxOfMax[secondIndex >> Node48::kMaxOfMaxShift] = - std::max(self48->maxOfMax[secondIndex >> Node48::kMaxOfMaxShift], - newMaxVersion); - } + consumePartialKey(self48->children[secondIndex], key, newMaxVersion, tls); + self48->childMaxVersion[secondIndex] = newMaxVersion; + self48->maxOfMax[secondIndex >> Node48::kMaxOfMaxShift] = + std::max(self48->maxOfMax[secondIndex >> Node48::kMaxOfMaxShift], + newMaxVersion); return self48->children[secondIndex]; } } break; case Type_Node256: { auto *self256 = static_cast(self); if (auto &result = self256->children[index]; result != nullptr) { - if (self256->children[index]->partialKeyLen == 0) { - self256->childMaxVersion[index] = newMaxVersion; - self256->maxOfMax[index >> Node256::kMaxOfMaxShift] = std::max( - self256->maxOfMax[index >> Node256::kMaxOfMaxShift], newMaxVersion); - } + consumePartialKey(result, key, newMaxVersion, tls); + self256->childMaxVersion[index] = newMaxVersion; + self256->maxOfMax[index >> Node256::kMaxOfMaxShift] = std::max( + self256->maxOfMax[index >> Node256::kMaxOfMaxShift], newMaxVersion); return result; } } break; @@ -2815,10 +2811,6 @@ Node **insert(Node **self, std::span key, } self = &child; - - consumePartialKey(*self, key, writeVersion, tls); - assert(maxVersion(*self, impl) <= writeVersion); - setMaxVersion(*self, impl, writeVersion); } }