]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Simplify code using std::adjacent_find. 13231/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 13 Jan 2022 17:58:18 +0000 (10:58 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 13 Jan 2022 17:58:18 +0000 (10:58 -0700)
source/base/mpi.cc

index 53ac3bbb431223ba2410bda8ea3d616b25a78be8..6d04a9b395526e36adb34fe35d5e3b86c5fc2c24 100644 (file)
@@ -419,12 +419,9 @@ namespace Utilities
           {
             std::vector<unsigned int> my_destinations = destinations;
             std::sort(my_destinations.begin(), my_destinations.end());
-
-            for (unsigned int i = 0; i < my_destinations.size() - 1; ++i)
-              if (my_destinations[i] == my_destinations[i + 1])
-                return false;
-
-            return true;
+            return (std::adjacent_find(my_destinations.begin(),
+                                       my_destinations.end()) ==
+                    my_destinations.end());
           }
       }();
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.