]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use range-based for loop in source/distributed 7595/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sun, 6 Jan 2019 18:54:44 +0000 (19:54 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sat, 12 Jan 2019 14:03:09 +0000 (15:03 +0100)
source/distributed/tria.cc
source/distributed/tria_base.cc

index fb1eb28f5971ae2d050643d94a0a635406348fef..0b0ad8c5e06229a812caa8fa24cc5b5812e29606 100644 (file)
@@ -1355,15 +1355,13 @@ namespace parallel
       // following loops will be skipped.
       std::vector<unsigned int> local_sizes_fixed(
         1 + n_callbacks_fixed + (variable_size_data_stored ? 1 : 0));
-      for (auto data_cell_fixed_it = packed_fixed_size_data.cbegin();
-           data_cell_fixed_it != packed_fixed_size_data.cend();
-           ++data_cell_fixed_it)
+      for (const auto &data_cell : packed_fixed_size_data)
         {
-          if (data_cell_fixed_it->size() == local_sizes_fixed.size())
+          if (data_cell.size() == local_sizes_fixed.size())
             {
               auto sizes_fixed_it = local_sizes_fixed.begin();
-              auto data_fixed_it  = data_cell_fixed_it->cbegin();
-              for (; data_fixed_it != data_cell_fixed_it->cend();
+              auto data_fixed_it  = data_cell.cbegin();
+              for (; data_fixed_it != data_cell.cend();
                    ++data_fixed_it, ++sizes_fixed_it)
                 {
                   *sizes_fixed_it = data_fixed_it->size();
@@ -1404,16 +1402,12 @@ namespace parallel
       if (variable_size_data_stored)
         {
           src_sizes_variable.reserve(packed_variable_size_data.size());
-          for (auto data_cell_variable_it = packed_variable_size_data.cbegin();
-               data_cell_variable_it != packed_variable_size_data.cend();
-               ++data_cell_variable_it)
+          for (const auto &data_cell : packed_variable_size_data)
             {
               int variable_data_size_on_cell = 0;
 
-              for (auto data_variable_it = data_cell_variable_it->cbegin();
-                   data_variable_it != data_cell_variable_it->cend();
-                   ++data_variable_it)
-                variable_data_size_on_cell += data_variable_it->size();
+              for (const auto &data : data_cell)
+                variable_data_size_on_cell += data.size();
 
               src_sizes_variable.push_back(variable_data_size_on_cell);
             }
@@ -1431,24 +1425,20 @@ namespace parallel
 
       // Move every piece of packed fixed size data into the consecutive buffer.
       src_data_fixed.reserve(expected_size_fixed);
-      for (auto data_cell_fixed_it = packed_fixed_size_data.begin();
-           data_cell_fixed_it != packed_fixed_size_data.end();
-           ++data_cell_fixed_it)
+      for (const auto &data_cell_fixed : packed_fixed_size_data)
         {
           // Move every fraction of packed data into the buffer
           // reserved for this particular cell.
-          for (auto data_fixed_it = data_cell_fixed_it->begin();
-               data_fixed_it != data_cell_fixed_it->end();
-               ++data_fixed_it)
-            std::move(data_fixed_it->begin(),
-                      data_fixed_it->end(),
+          for (const auto &data_fixed : data_cell_fixed)
+            std::move(data_fixed.begin(),
+                      data_fixed.end(),
                       std::back_inserter(src_data_fixed));
 
           // If we only packed the CellStatus information
           // (i.e. encountered a cell flagged CELL_INVALID),
           // fill the remaining space with invalid entries.
           // We can skip this if there is nothing else to pack.
-          if ((data_cell_fixed_it->size() == 1) &&
+          if ((data_cell_fixed.size() == 1) &&
               (sizes_fixed_cumulative.size() > 1))
             {
               const std::size_t bytes_skipped =
@@ -1465,17 +1455,13 @@ namespace parallel
       if (variable_size_data_stored)
         {
           src_data_variable.reserve(expected_size_variable);
-          for (auto data_cell_variable_it = packed_variable_size_data.begin();
-               data_cell_variable_it != packed_variable_size_data.end();
-               ++data_cell_variable_it)
+          for (const auto &data_cell : packed_variable_size_data)
             {
               // Move every fraction of packed data into the buffer
               // reserved for this particular cell.
-              for (auto data_variable_it = data_cell_variable_it->begin();
-                   data_variable_it != data_cell_variable_it->end();
-                   ++data_variable_it)
-                std::move(data_variable_it->begin(),
-                          data_variable_it->end(),
+              for (const auto &data : data_cell)
+                std::move(data.begin(),
+                          data.end(),
                           std::back_inserter(src_data_variable));
             }
         }
@@ -2497,13 +2483,8 @@ namespace parallel
                       }
 
                   if (vertex_indices.size() > 0)
-                    for (std::set<dealii::types::subdomain_id>::iterator it =
-                           send_to.begin();
-                         it != send_to.end();
-                         ++it)
+                    for (const auto subdomain : send_to)
                       {
-                        const dealii::types::subdomain_id subdomain = *it;
-
                         // get an iterator to what needs to be sent to that
                         // subdomain (if already exists), or create such an
                         // object
index 6b8c6be65aa77a2119dfd429980975181a5d8275..0e6b0e560b21e7c96929b7a2742075bccc8177b4 100644 (file)
@@ -370,13 +370,13 @@ namespace parallel
 
     std::vector<bool> vertex_of_own_cell(this->n_vertices(), false);
 
-    for (auto cell : this->active_cell_iterators())
+    for (const auto &cell : this->active_cell_iterators())
       if (cell->is_locally_owned())
         for (unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell; ++v)
           vertex_of_own_cell[cell->vertex_index(v)] = true;
 
     std::map<unsigned int, std::set<dealii::types::subdomain_id>> result;
-    for (auto cell : this->active_cell_iterators())
+    for (const auto &cell : this->active_cell_iterators())
       if (cell->is_ghost())
         {
           const types::subdomain_id owner = cell->subdomain_id();

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.