]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Pre-allocate the size of an array. 13895/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 2 Jun 2022 13:54:53 +0000 (07:54 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 2 Jun 2022 13:54:53 +0000 (07:54 -0600)
source/base/mpi_compute_index_owner_internal.cc

index 8f1dd43b969f6ce4d1ca508250f9c4542610708e..c96e46a9f05e62353ec02715ffb7a664d3fe6898 100644 (file)
@@ -354,8 +354,9 @@ namespace Utilities
                 /* targets = */
                 [&buffers]() {
                   std::vector<unsigned int> targets;
+                  targets.reserve(buffers.size());
                   for (const auto &rank_pair : buffers)
-                    targets.push_back(rank_pair.first);
+                    targets.emplace_back(rank_pair.first);
 
                   return targets;
                 }(),

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.