Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Dynamic cast without checking result is slow and useless. Use static cast.
[simgrid.git] / include / simgrid / s4u / Engine.hpp
index ae82253..cc6a2a8 100644 (file)
@@ -306,8 +306,9 @@ template <class T> XBT_PRIVATE void get_filtered_netzones_recursive(s4u::NetZone
                 "Filtering netzones is only possible for subclasses of kernel::routing::NetZoneImpl");
   for (auto const& elem : current->get_children()) {
     get_filtered_netzones_recursive(elem, whereto);
-    if (elem->get_impl() == dynamic_cast<T*>(elem->get_impl()))
-      whereto->push_back(dynamic_cast<T*>(elem->get_impl()));
+    T* elem_impl = dynamic_cast<T*>(elem->get_impl());
+    if (elem_impl != nullptr)
+      whereto->push_back(elem_impl);
   }
 }
 #endif