From 0349ac3b135081e15feac0cc2af4ae084b05dbd4 Mon Sep 17 00:00:00 2001 From: Andrea Iob Date: Wed, 23 Sep 2020 21:42:06 +0200 Subject: [PATCH] voloctree: move vector declarations outside loop to reduce reallocations --- src/voloctree/voloctree.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/voloctree/voloctree.cpp b/src/voloctree/voloctree.cpp index 04f053f64b..c52517cbd9 100644 --- a/src/voloctree/voloctree.cpp +++ b/src/voloctree/voloctree.cpp @@ -995,11 +995,14 @@ std::vector VolOctree::sync(bool trackChanges) } uint32_t treeId = 0; + std::vector mapper_octantMap; + std::vector mapper_ghostFlag; + std::vector mapper_octantRank; while (treeId < (uint32_t) nOctants) { // Octant mapping - std::vector mapper_octantMap; - std::vector mapper_ghostFlag; - std::vector mapper_octantRank; + mapper_octantMap.clear(); + mapper_ghostFlag.clear(); + mapper_octantRank.clear(); if (!importFromScratch) { m_tree->getMapping(treeId, mapper_octantMap, mapper_ghostFlag, mapper_octantRank); }