From: Timo Heister Date: Wed, 30 Oct 2013 23:08:33 +0000 (+0000) Subject: reserve then resize trick to not allocate more elements than needed X-Git-Tag: v8.1.0~446 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46e82303b339291d3825bfa833d21a48df912ac2;p=dealii.git reserve then resize trick to not allocate more elements than needed git-svn-id: https://svn.dealii.org/trunk@31491 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/source/grid/tria_objects.cc b/deal.II/source/grid/tria_objects.cc index 308f55033c..e3358d6c58 100644 --- a/deal.II/source/grid/tria_objects.cc +++ b/deal.II/source/grid/tria_objects.cc @@ -192,7 +192,11 @@ namespace internal RefinementCase::no_refinement); } - boundary_or_material_id.resize (new_size); + // first reserve, then resize. Otherwise the std library can decide to allocate + // more entries. + boundary_or_material_id.reserve (new_size); + boundary_or_material_id.resize (new_size); + user_data.reserve (new_size); user_data.resize (new_size); }