Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[smpi] Prefer range-based for loop.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 20 Feb 2021 10:27:14 +0000 (11:27 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 22 Feb 2021 15:54:46 +0000 (16:54 +0100)
src/smpi/internals/smpi_global.cpp

index 08eddf8..966df24 100644 (file)
@@ -642,16 +642,14 @@ void SMPI_finalize()
                "Running smpirun with -wrapper \"valgrind --leak-check=full\" can provide more information",
                simgrid::smpi::F2C::lookup()->size() - simgrid::smpi::F2C::get_num_default_handles());
       int n = simgrid::config::get_value<int>("smpi/list-leaks");
-      if (n > 0) {
-        std::for_each(simgrid::smpi::F2C::lookup()->begin(),
-                  simgrid::smpi::F2C::lookup()->end(),
-                  [n](const std::pair<unsigned int, simgrid::smpi::F2C*> &p) {
-                      static int printed = 0;
-                      if(p.first >= simgrid::smpi::F2C::get_num_default_handles() && printed < n){
-                        XBT_WARN ("Leak %p of type %s", p.second, boost::core::demangle(typeid(*(p.second)).name()).c_str() );
-                        printed++;
-                      }
-                  });
+      for (auto const& p : *simgrid::smpi::F2C::lookup()) {
+        static int printed = 0;
+        if (printed >= n)
+          break;
+        if (p.first >= simgrid::smpi::F2C::get_num_default_handles()) {
+          XBT_WARN("Leak %p of type %s", p.second, boost::core::demangle(typeid(*(p.second)).name()).c_str());
+          printed++;
+        }
       }
     }
     simgrid::smpi::F2C::delete_lookup();