]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Simplify code slightly. 15040/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 6 Apr 2023 23:17:50 +0000 (17:17 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 6 Apr 2023 23:17:50 +0000 (17:17 -0600)
Avoid using a second counter in a range-based for loop, which always looks a bit awkward.

source/grid/grid_tools_cache.cc

index 4caa9a671a308efd33aa47277f7a78cf3cf39d30..596959ef691e34b2a855ceb5fa1a1bfd57dd40dd 100644 (file)
@@ -130,10 +130,10 @@ namespace GridTools
         std::vector<std::pair<
           BoundingBox<spacedim>,
           typename Triangulation<dim, spacedim>::active_cell_iterator>>
-                     boxes(tria->n_active_cells());
-        unsigned int i = 0;
+          boxes;
+        boxes.reserve(tria->n_active_cells());
         for (const auto &cell : tria->active_cell_iterators())
-          boxes[i++] = std::make_pair(mapping->get_bounding_box(cell), cell);
+          boxes.emplace_back(mapping->get_bounding_box(cell), cell);
 
         cell_bounding_boxes_rtree = pack_rtree(boxes);
         update_flags = update_flags & ~update_cell_bounding_boxes_rtree;

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.