]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Avoid using a std::set. Use std::vector instead. 15730/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 14 Jul 2023 19:27:52 +0000 (13:27 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 14 Jul 2023 19:27:52 +0000 (13:27 -0600)
include/deal.II/lac/affine_constraints.templates.h

index 189bc8d543cf3eb6d5d50d96c7993bc0f4ed4db6..c33d9aef95fca21ea3b8f5b7699275f90058a155 100644 (file)
@@ -715,6 +715,7 @@ AffineConstraints<number>::close()
   bool                                chained_constraint_replaced = false;
   std::vector<bool>                   line_finalized(lines.size(), false);
   std::vector<const ConstraintLine *> sub_constraints;
+  std::vector<unsigned int>           entries_to_delete;
   do
     {
       chained_constraint_replaced = false;
@@ -775,8 +776,8 @@ AffineConstraints<number>::close()
             // to disturb the order of the correspondence between lines.entries
             // and sub_constraints, we store up which entries we will later
             // have to delete.
-            const unsigned int     n_original_entries = line.entries.size();
-            std::set<unsigned int> entries_to_delete;
+            const unsigned int n_original_entries = line.entries.size();
+            entries_to_delete.clear();
             for (unsigned int entry = 0; entry < n_original_entries; ++entry)
               if (sub_constraints[entry] != nullptr)
                 {
@@ -839,7 +840,7 @@ AffineConstraints<number>::close()
                     // empty). in that case, we can't just overwrite the
                     // current entry, but we have to actually eliminate it
                     {
-                      entries_to_delete.insert(entry);
+                      entries_to_delete.emplace_back(entry);
                     }
 
                   line.inhomogeneity += constrained_line.inhomogeneity * weight;
@@ -851,6 +852,7 @@ AffineConstraints<number>::close()
             // we have already erased earlier elements (as we would have to
             // do if we walked the list of entries to delete in forward
             // order).
+            std::sort(entries_to_delete.begin(), entries_to_delete.end());
             for (auto it = entries_to_delete.rbegin();
                  it != entries_to_delete.rend();
                  ++it)

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.