From: David Wells Date: Sat, 1 Apr 2017 16:53:46 +0000 (-0400) Subject: Resize a vector instead of repeatedly calling push_back. X-Git-Tag: v9.0.0-rc1~1753^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6c42fd7bf9745d1bdbcbd058b235ab0eaf05ffd;p=dealii.git Resize a vector instead of repeatedly calling push_back. std::vector(0) creates an empty vector, so we can save some time by just resizing the vector of vectors instead. --- diff --git a/source/numerics/point_value_history.cc b/source/numerics/point_value_history.cc index fbd5d18d1e..fe1ac2fb8a 100644 --- a/source/numerics/point_value_history.cc +++ b/source/numerics/point_value_history.cc @@ -309,10 +309,7 @@ void PointValueHistory // entry const ComponentMask ¤t_mask = (component_mask.find (data_store_begin->first))->second; unsigned int n_stored = current_mask.n_selected_components(); - for (unsigned int component = 0; component < n_stored; component++) - { - data_store_begin->second.push_back (std::vector (0)); - } + data_store_begin->second.resize(data_store_begin->second.size() + n_stored); } } @@ -429,10 +426,7 @@ void PointValueHistory // entry const ComponentMask current_mask = (component_mask.find (data_store_begin->first))->second; unsigned int n_stored = current_mask.n_selected_components(); - for (unsigned int component = 0; component < n_stored; component++) - { - data_store_begin->second.push_back (std::vector (0)); - } + data_store_begin->second.resize(data_store_begin->second.size() + n_stored); } } }