From 99d82f5e62cf54e8eb23cb5e5d2c25cf6eb9eed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 18 Dec 2021 20:21:35 +0100 Subject: [PATCH] SceneTools: we don't need growable arrays in orderClusterParents(). --- src/Magnum/SceneTools/OrderClusterParents.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Magnum/SceneTools/OrderClusterParents.cpp b/src/Magnum/SceneTools/OrderClusterParents.cpp index db41636ab..60025f560 100644 --- a/src/Magnum/SceneTools/OrderClusterParents.cpp +++ b/src/Magnum/SceneTools/OrderClusterParents.cpp @@ -26,7 +26,6 @@ #include "OrderClusterParents.h" #include -#include #include #include @@ -94,9 +93,9 @@ void orderClusterParentsInto(const Trade::SceneData& scene, const Containers::St other) and build a list of (id, parent id) where a parent is always before its children */ std::size_t outputOffset = 0; - Containers::Array parentsToProcess; - arrayAppend(parentsToProcess, -1); - for(std::size_t i = 0; i != parentsToProcess.size(); ++i) { + Containers::Array parentsToProcess{NoInit, parents.size() + 1}; + parentsToProcess[0] = -1; + for(std::size_t i = 0; i != outputOffset + 1; ++i) { const Int objectId = parentsToProcess[i]; for(std::size_t j = childrenOffsets[objectId + 1], jMax = childrenOffsets[objectId + 2]; j != jMax; ++j) { /** @todo better diagnostic once we can use a BitArray to detect @@ -105,7 +104,7 @@ void orderClusterParentsInto(const Trade::SceneData& scene, const Containers::St should be instead in a dedicated cycle/sparse checker utility?) */ CORRADE_ASSERT_OUTPUT(outputOffset < parents.size(), "SceneTools::orderClusterParents(): hierarchy is cyclic", ); - arrayAppend(parentsToProcess, children[j]); + parentsToProcess[outputOffset + 1] = children[j]; mappingDestination[outputOffset] = children[j]; parentDestination[outputOffset] = objectId; ++outputOffset;