From 17ac9b38fbcd8f6417c94bb4826d0f9f6e7c2048 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Mon, 26 Feb 2024 10:37:28 -0800 Subject: [PATCH] Use forEachInRange in setChildrenParents --- ConflictSet.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 434c5fd..96cfe97 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -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