From 1d216335d07a38d0c70eb0496dbc015ba62b1b3d Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Fri, 15 Jan 2021 10:19:14 +0100
Subject: [PATCH] [GL/SurfaceGrid] Use find_if instead of raw loop.

---
 GeoLib/SurfaceGrid.cpp | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/GeoLib/SurfaceGrid.cpp b/GeoLib/SurfaceGrid.cpp
index c4aa795b0db..3f66c58e6ad 100644
--- a/GeoLib/SurfaceGrid.cpp
+++ b/GeoLib/SurfaceGrid.cpp
@@ -213,16 +213,11 @@ bool SurfaceGrid::isPointInSurface(MathLib::Point3d const& pnt,
 
     std::size_t const grid_cell_idx(c[0]+c[1]*_n_steps[0]+c[2]*_n_steps[0]*_n_steps[1]);
     std::vector<Triangle const*> const& triangles(_triangles_in_grid_box[grid_cell_idx]);
-    bool nfound(true);
-    const std::size_t n_triangles(triangles.size());
-    for (std::size_t k(0); k < n_triangles && nfound; k++) {
-        if (triangles[k]->containsPoint(pnt, eps))
-        {
-            nfound = false;
-        }
-    }
-
-    return !nfound;
+    auto const it = std::find_if(triangles.begin(), triangles.end(),
+                                 [eps, pnt](auto const* triangle) {
+                                     return triangle->containsPoint(pnt, eps);
+                                 });
+    return it != triangles.end();
 }
 
 } // end namespace GeoLib
-- 
GitLab