]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Rename a lambda function and make it easier to read. 15416/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Wed, 21 Jun 2023 15:35:56 +0000 (09:35 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Wed, 21 Jun 2023 18:00:05 +0000 (12:00 -0600)
The function is currently called 'sort_constraints()', but it also makes
the elements of a vector unique. So call it 'sort_and_make_unique()'
instead.

More importantly, though, the function operates on a vector that it captures
by reference. That makes it hard to read at the place where it is called what
it works on. Make this more obvious by letting it take the object it works on
as an argument.

include/deal.II/lac/affine_constraints.templates.h

index f385c042842b2b5f68cb9bbec7c6b0af090e9cd5..bfda083cc141462472ad54953c347d77ad821130 100644 (file)
@@ -218,15 +218,13 @@ namespace internal
       Utilities::MPI::this_mpi_process(mpi_communicator);
 
     // helper function
-    const auto sort_constraints = [&]() {
-      std::sort(locally_relevant_constraints.begin(),
-                locally_relevant_constraints.end());
-
-      locally_relevant_constraints.erase(
-        std::unique(locally_relevant_constraints.begin(),
-                    locally_relevant_constraints.end()),
-        locally_relevant_constraints.end());
-    };
+    const auto sort_and_make_unique =
+      [](std::vector<ConstraintType> &constraints) {
+        std::sort(constraints.begin(), constraints.end());
+
+        constraints.erase(std::unique(constraints.begin(), constraints.end()),
+                          constraints.end());
+      };
 
     // 0) collect constrained indices of the current object
     IndexSet constrained_indices(locally_owned_dofs.size());
@@ -352,7 +350,7 @@ namespace internal
         MPI_Waitall(requests.size(), requests.data(), MPI_STATUSES_IGNORE);
       AssertThrowMPI(ierr);
 
-      sort_constraints();
+      sort_and_make_unique(locally_relevant_constraints);
     }
 
     // step 3: communicate constraints so that each process know how the
@@ -472,7 +470,7 @@ namespace internal
         MPI_Waitall(requests.size(), requests.data(), MPI_STATUSES_IGNORE);
       AssertThrowMPI(ierr);
 
-      sort_constraints();
+      sort_and_make_unique(locally_relevant_constraints);
     }
 
 #endif

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.