Skip to content
Permalink
Browse files

[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 2c6948382d55cb6cd2dc021ab4d8bf0943175c58
Showing with 2 additions and 0 deletions.
  1. +2 −0 src/analysis/raster/qgsrelief.cpp
@@ -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 ) );
@@ -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] ) );

0 comments on commit 2c69483

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