Simplify nextPhysical

This commit is contained in:
2024-08-01 14:00:02 -07:00
parent c86e407985
commit adb8fdc5e9

View File

@@ -1257,44 +1257,9 @@ Node *&getOrCreateChild(Node *&self, uint8_t index, WriteContext *tls) {
Node *nextPhysical(Node *node) {
int index = -1;
for (;;) {
switch (node->getType()) {
case Type_Node0: {
auto *n = static_cast<Node0 *>(node);
auto nextChild = getChildGeq(n, index + 1);
if (nextChild != nullptr) {
return nextChild;
}
} break;
case Type_Node3: {
auto *n = static_cast<Node3 *>(node);
auto nextChild = getChildGeq(n, index + 1);
if (nextChild != nullptr) {
return nextChild;
}
} break;
case Type_Node16: {
auto *n = static_cast<Node16 *>(node);
auto nextChild = getChildGeq(n, index + 1);
if (nextChild != nullptr) {
return nextChild;
}
} break;
case Type_Node48: {
auto *n = static_cast<Node48 *>(node);
auto nextChild = getChildGeq(n, index + 1);
if (nextChild != nullptr) {
return nextChild;
}
} break;
case Type_Node256: {
auto *n = static_cast<Node256 *>(node);
auto nextChild = getChildGeq(n, index + 1);
if (nextChild != nullptr) {
return nextChild;
}
} break;
default: // GCOVR_EXCL_LINE
__builtin_unreachable(); // GCOVR_EXCL_LINE
auto nextChild = getChildGeq(node, index + 1);
if (nextChild != nullptr) {
return nextChild;
}
index = node->parentsIndex;
node = node->parent;