Add overloads of getChild for each type
This commit is contained in:
@@ -891,29 +891,33 @@ void setMaxVersion(Node *n, ConflictSet::Impl *, InternalVersionT maxVersion);
|
|||||||
|
|
||||||
Node *&getInTree(Node *n, ConflictSet::Impl *);
|
Node *&getInTree(Node *n, ConflictSet::Impl *);
|
||||||
|
|
||||||
|
Node *getChild(Node0 *, uint8_t) { return nullptr; }
|
||||||
|
Node *getChild(Node3 *self, uint8_t index) {
|
||||||
|
int i = getNodeIndex(self, index);
|
||||||
|
return i < 0 ? nullptr : self->children[i];
|
||||||
|
}
|
||||||
|
Node *getChild(Node16 *self, uint8_t index) {
|
||||||
|
int i = getNodeIndex(self, index);
|
||||||
|
return i < 0 ? nullptr : self->children[i];
|
||||||
|
}
|
||||||
|
Node *getChild(Node48 *self, uint8_t index) {
|
||||||
|
int i = self->index[index];
|
||||||
|
return i < 0 ? nullptr : self->children[i];
|
||||||
|
}
|
||||||
|
Node *getChild(Node256 *self, uint8_t index) { return self->children[index]; }
|
||||||
|
|
||||||
Node *getChild(Node *self, uint8_t index) {
|
Node *getChild(Node *self, uint8_t index) {
|
||||||
switch (self->getType()) {
|
switch (self->getType()) {
|
||||||
case Type_Node0:
|
case Type_Node0:
|
||||||
return nullptr;
|
return getChild(static_cast<Node0 *>(self), index);
|
||||||
case Type_Node3: {
|
case Type_Node3:
|
||||||
auto *self3 = static_cast<Node3 *>(self);
|
return getChild(static_cast<Node3 *>(self), index);
|
||||||
int i = getNodeIndex(self3, index);
|
case Type_Node16:
|
||||||
return i < 0 ? nullptr : self3->children[i];
|
return getChild(static_cast<Node16 *>(self), index);
|
||||||
}
|
case Type_Node48:
|
||||||
case Type_Node16: {
|
return getChild(static_cast<Node48 *>(self), index);
|
||||||
auto *self16 = static_cast<Node16 *>(self);
|
case Type_Node256:
|
||||||
int i = getNodeIndex(self16, index);
|
return getChild(static_cast<Node256 *>(self), index);
|
||||||
return i < 0 ? nullptr : self16->children[i];
|
|
||||||
}
|
|
||||||
case Type_Node48: {
|
|
||||||
auto *self48 = static_cast<Node48 *>(self);
|
|
||||||
int i = self48->index[index];
|
|
||||||
return i < 0 ? nullptr : self48->children[i];
|
|
||||||
}
|
|
||||||
case Type_Node256: {
|
|
||||||
auto *self256 = static_cast<Node256 *>(self);
|
|
||||||
return self256->children[index];
|
|
||||||
}
|
|
||||||
default: // GCOVR_EXCL_LINE
|
default: // GCOVR_EXCL_LINE
|
||||||
__builtin_unreachable(); // GCOVR_EXCL_LINE
|
__builtin_unreachable(); // GCOVR_EXCL_LINE
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user