From ffef266bd8f652947d4ece62cac1ec1603e11840 Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Thu, 28 May 2020 10:59:42 +0200
Subject: [PATCH] [GL] OctTree: use copy_if instead of raw loop.

---
 GeoLib/OctTree-impl.h | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/GeoLib/OctTree-impl.h b/GeoLib/OctTree-impl.h
index f112e7f6723..d7d975de366 100644
--- a/GeoLib/OctTree-impl.h
+++ b/GeoLib/OctTree-impl.h
@@ -128,13 +128,12 @@ void OctTree<POINT, MAX_POINTS>::getPointsInRange(T const& min, T const& max,
     }
 
     if (_is_leaf) {
-        for (auto p : _pnts) {
-            if (min[0] <= (*p)[0] && (*p)[0] < max[0] && min[1] <= (*p)[1] &&
-                (*p)[1] < max[1] && min[2] <= (*p)[2] && (*p)[2] < max[2])
-            {
-                pnts.push_back(p);
-            }
-        }
+        std::copy_if(_pnts.begin(), _pnts.end(), std::back_inserter(pnts),
+                     [&min, &max](auto const* p) {
+                         return (min[0] <= (*p)[0] && (*p)[0] < max[0] &&
+                                 min[1] <= (*p)[1] && (*p)[1] < max[1] &&
+                                 min[2] <= (*p)[2] && (*p)[2] < max[2]);
+                     });
     } else {
         for (std::size_t k(0); k<8; k++) {
             _children[k]->getPointsInRange(min, max, pnts);
-- 
GitLab