Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Minor] 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 28, 2019
1 parent 3a19182 commit 2c69483
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 2c69483

Please sign in to comment.