From: Wolfgang Bangerth Date: Thu, 29 Nov 2001 15:11:50 +0000 (+0000) Subject: Slightly improve memory allocation. X-Git-Tag: v8.0.0~18524 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c264823164e8b49eacbb5a8f1f7e0cb6f522ba9;p=dealii.git Slightly improve memory allocation. git-svn-id: https://svn.dealii.org/trunk@5311 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/dofs/dof_handler.cc b/deal.II/deal.II/source/dofs/dof_handler.cc index fe4818a029..fb1bb3fc4b 100644 --- a/deal.II/deal.II/source/dofs/dof_handler.cc +++ b/deal.II/deal.II/source/dofs/dof_handler.cc @@ -1825,15 +1825,15 @@ template <> void DoFHandler<1>::reserve_space () { Assert (selected_fe != 0, ExcNoFESelected()); Assert (tria->n_levels() > 0, ExcInvalidTriangulation()); + // delete all levels and set them up // newly, since vectors are // troublesome if you want to change // their size clear_space (); - vertex_dofs = std::vector(tria->vertices.size()* - selected_fe->dofs_per_vertex, - invalid_dof_index); + vertex_dofs.resize(tria->vertices.size()*selected_fe->dofs_per_vertex, + invalid_dof_index); for (unsigned int i=0; in_levels(); ++i) { @@ -1862,9 +1862,9 @@ void DoFHandler<2>::reserve_space () { // their size clear_space (); - vertex_dofs = std::vector(tria->vertices.size()* - selected_fe->dofs_per_vertex, - invalid_dof_index); + vertex_dofs.resize(tria->vertices.size()*selected_fe->dofs_per_vertex, + invalid_dof_index); + for (unsigned int i=0; in_levels(); ++i) { levels.push_back (new DoFLevel<2>); @@ -1894,9 +1894,9 @@ void DoFHandler<3>::reserve_space () { // their size clear_space (); - vertex_dofs = std::vector(tria->vertices.size()* - selected_fe->dofs_per_vertex, - invalid_dof_index); + vertex_dofs.resize(tria->vertices.size()*selected_fe->dofs_per_vertex, + invalid_dof_index); + for (unsigned int i=0; in_levels(); ++i) { levels.push_back (new DoFLevel<3>); @@ -1921,6 +1921,9 @@ void DoFHandler::clear_space () { for (unsigned int i=0; i tmp; + std::swap (vertex_dofs, tmp); };