From 2c6948382d55cb6cd2dc021ab4d8bf0943175c58 Mon Sep 17 00:00:00 2001 From: Shahzad Lone Date: Mon, 28 Jan 2019 16:00:05 -0500 Subject: [PATCH] [Minor] Reserve vector - to minimize reallocation costs Reserving vector to save on reallocation costs, where we know the size in advance. --- src/analysis/raster/qgsrelief.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/analysis/raster/qgsrelief.cpp b/src/analysis/raster/qgsrelief.cpp index 27c0547fae91..4a9c9209f87c 100644 --- a/src/analysis/raster/qgsrelief.cpp +++ b/src/analysis/raster/qgsrelief.cpp @@ -639,6 +639,7 @@ QList< QgsRelief::ReliefColor > QgsRelief::calculateOptimizedReliefClasses() //set colors according to optimised class breaks QVector 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 &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] ) );