Return tagged pointer from getChild

This commit is contained in:
2024-10-10 10:24:38 -07:00
parent b9c642d81d
commit cafa540fc8

View File

@@ -1104,22 +1104,24 @@ void setMaxVersion(Node *n, InternalVersionT newMax) {
TaggedNodePointer &getInTree(Node *n, ConflictSet::Impl *); TaggedNodePointer &getInTree(Node *n, ConflictSet::Impl *);
Node *getChild(Node0 *, uint8_t) { return nullptr; } TaggedNodePointer getChild(Node0 *, uint8_t) { return nullptr; }
Node *getChild(Node3 *self, uint8_t index) { TaggedNodePointer getChild(Node3 *self, uint8_t index) {
int i = getNodeIndex(self, index); int i = getNodeIndex(self, index);
return i < 0 ? nullptr : self->children[i]; return i < 0 ? nullptr : self->children[i];
} }
Node *getChild(Node16 *self, uint8_t index) { TaggedNodePointer getChild(Node16 *self, uint8_t index) {
int i = getNodeIndex(self, index); int i = getNodeIndex(self, index);
return i < 0 ? nullptr : self->children[i]; return i < 0 ? nullptr : self->children[i];
} }
Node *getChild(Node48 *self, uint8_t index) { TaggedNodePointer getChild(Node48 *self, uint8_t index) {
int i = self->index[index]; int i = self->index[index];
return i < 0 ? nullptr : self->children[i]; return i < 0 ? nullptr : self->children[i];
} }
Node *getChild(Node256 *self, uint8_t index) { return self->children[index]; } TaggedNodePointer getChild(Node256 *self, uint8_t index) {
return self->children[index];
}
Node *getChild(Node *self, uint8_t index) { TaggedNodePointer getChild(Node *self, uint8_t index) {
switch (self->getType()) { switch (self->getType()) {
case Type_Node0: case Type_Node0:
return getChild(static_cast<Node0 *>(self), index); return getChild(static_cast<Node0 *>(self), index);
@@ -2579,7 +2581,7 @@ bool checkRangeStartsWith(Node *n, std::span<const uint8_t> key, int begin,
return checkMaxBetweenExclusive(n, begin, end, readVersion, tls); return checkMaxBetweenExclusive(n, begin, end, readVersion, tls);
} }
auto *child = getChild(n, remaining[0]); Node *child = getChild(n, remaining[0]);
if (child == nullptr) { if (child == nullptr) {
auto c = getChildGeq(n, remaining[0]); auto c = getChildGeq(n, remaining[0]);
if (c != nullptr) { if (c != nullptr) {
@@ -2746,7 +2748,7 @@ bool checkRangeRightSide(Node *n, std::span<const uint8_t> key, int prefixLen,
return false; return false;
} }
auto *child = getChild(n, remaining[0]); Node *child = getChild(n, remaining[0]);
if (child == nullptr) { if (child == nullptr) {
auto c = getChildGeq(n, remaining[0]); auto c = getChildGeq(n, remaining[0]);
if (c != nullptr) { if (c != nullptr) {
@@ -3160,7 +3162,7 @@ Node *firstGeqPhysical(Node *n, const std::span<const uint8_t> key) {
return n; return n;
} }
auto *child = getChild(n, remaining[0]); Node *child = getChild(n, remaining[0]);
if (child == nullptr) { if (child == nullptr) {
auto c = getChildGeq(n, remaining[0]); auto c = getChildGeq(n, remaining[0]);
if (c != nullptr) { if (c != nullptr) {
@@ -3612,7 +3614,7 @@ Node *firstGeqLogical(Node *n, const std::span<const uint8_t> key) {
goto downLeftSpine; goto downLeftSpine;
} }
auto *child = getChild(n, remaining[0]); Node *child = getChild(n, remaining[0]);
if (child == nullptr) { if (child == nullptr) {
auto c = getChildGeq(n, remaining[0]); auto c = getChildGeq(n, remaining[0]);
if (c != nullptr) { if (c != nullptr) {