Skip to content

Commit

Permalink
Reserve vector - to minimize reallocation costs
Browse files Browse the repository at this point in the history
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 4559d9e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/analysis/mesh/qgsmeshcalculator.cpp
Expand Up @@ -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 );

Expand Down

0 comments on commit 4559d9e

Please sign in to comment.