From: Marc Fehling <mafehling.git@gmail.com>
Date: Thu, 10 Mar 2022 05:04:26 +0000 (-0700)
Subject: Reserve internal container with correct size.
X-Git-Tag: v9.4.0-rc1~385^2
X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F13527%2Fhead;p=dealii.git

Reserve internal container with correct size.
---

diff --git a/source/distributed/tria.cc b/source/distributed/tria.cc
index 39f76f1e9f..257c0ccac2 100644
--- a/source/distributed/tria.cc
+++ b/source/distributed/tria.cc
@@ -4041,13 +4041,10 @@ namespace parallel
                static_cast<unsigned int>(parallel_forest->local_num_quadrants),
              ExcInternalError());
 
-      // Allocate the space for the weights. In fact we do not know yet, how
-      // many cells we own after the refinement (only p4est knows that
-      // at this point). We simply reserve n_active_cells space and if many
-      // more cells are refined than coarsened than additional reallocation
-      // will be done inside get_cell_weights_recursively.
+      // Allocate the space for the weights. We reserve an integer for each
+      // locally owned quadrant on the already refined p4est object.
       std::vector<unsigned int> weights;
-      weights.reserve(this->n_active_cells());
+      weights.reserve(this->local_cell_relations.size());
 
       // Iterate over p4est and Triangulation relations
       // to find refined/coarsened/kept