Skip to content

Commit

Permalink
[Minor] 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.

(cherry picked from commit 2c69483)
  • Loading branch information
shahzadlone authored and nyalldawson committed Jan 29, 2019
1 parent 1143502 commit 66c07d7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/analysis/raster/qgsrelief.cpp
Expand Up @@ -639,6 +639,7 @@ QList< QgsRelief::ReliefColor > QgsRelief::calculateOptimizedReliefClasses()

//set colors according to optimised class breaks
QVector<QColor> colorList;
colorList.reserve( 9 );
colorList.push_back( QColor( 7, 165, 144 ) );
colorList.push_back( QColor( 12, 221, 162 ) );
colorList.push_back( QColor( 33, 252, 183 ) );
Expand Down Expand Up @@ -670,6 +671,7 @@ void QgsRelief::optimiseClassBreaks( QList<int> &breaks, double *frequencies )
{
//get all the values between the class breaks into input
QList< QPair < int, double > > regressionInput;
regressionInput.reserve( breaks.at( i + 1 ) - breaks.at( i ) );
for ( int j = breaks.at( i ); j < breaks.at( i + 1 ); ++j )
{
regressionInput.push_back( qMakePair( j, frequencies[j] ) );
Expand Down

0 comments on commit 66c07d7

Please sign in to comment.