From a6c42fd7bf9745d1bdbcbd058b235ab0eaf05ffd Mon Sep 17 00:00:00 2001 From: David Wells Date: Sat, 1 Apr 2017 12:53:46 -0400 Subject: [PATCH] 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. --- source/numerics/point_value_history.cc | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) 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); } } } -- 2.39.5