Skip to content
Permalink
Browse files

Reserve vector - to minimize reallocation costs

Reserving vector to save on reallocation costs, where we know the size in advance.
  • Loading branch information
shahzadlone authored and nyalldawson committed Jan 30, 2019
1 parent 2e92dab commit 4559d9e496d0629559f86b554895ba1f48477666
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/analysis/mesh/qgsmeshcalculator.cpp
@@ -153,7 +153,11 @@ QgsMeshCalculator::Result QgsMeshCalculator::processCalculation( QgsFeedback *fe
QVector<QgsMeshDataBlock> datasetActive;
QVector<double> times;

for ( int i = 0; i < outputGroup->datasets.size(); ++i )
const auto datasize = outputGroup->datasets.size();
datasetValues.reserve( datasize );
times.reserve( datasize );

for ( int i = 0; i < datasize; ++i )
{
const std::shared_ptr<QgsMeshMemoryDataset> dataset = outputGroup->datasets.at( i );

0 comments on commit 4559d9e

Please sign in to comment.
You can’t perform that action at this time.