]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
reserve then resize trick to not allocate more elements than needed
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 30 Oct 2013 23:08:33 +0000 (23:08 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 30 Oct 2013 23:08:33 +0000 (23:08 +0000)
git-svn-id: https://svn.dealii.org/trunk@31491 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/source/grid/tria_objects.cc

index 308f55033c1e63e193850c9de852d2c2a2798975..e3358d6c58cb157df26cadb644b1d9488bea8aa8 100644 (file)
@@ -192,7 +192,11 @@ namespace internal
                                        RefinementCase<G::dimension>::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);
         }
 

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.