Use forEachInRange in setChildrenParents

This commit is contained in:
2024-02-26 10:37:28 -08:00
parent 172dd40648
commit 17ac9b38fb

View File

@@ -464,21 +464,13 @@ void setChildrenParents(Node16 *n) {
}
void setChildrenParents(Node48 *n) {
for (int i = 0; i < 256; ++i) {
int c = n->index[i];
if (c != -1) {
n->children[c].child->parent = n;
}
}
n->bitSet.forEachInRange(
[&](int i) { n->children[n->index[i]].child->parent = n; }, 0, 256);
}
void setChildrenParents(Node256 *n) {
for (int i = 0; i < 256; ++i) {
auto *child = n->children[i].child;
if (child != nullptr) {
child->parent = n;
}
}
n->bitSet.forEachInRange([&](int i) { n->children[i].child->parent = n; }, 0,
256);
}
// Caller is responsible for assigning a non-null pointer to the returned