Skip to content

Commit 9470c36

Browse files
committedMay 6, 2016
Change QList to QVector for speed increase
mLUT and mColorRampItemList are changed, for mLUT it shouldn't matter that much since an int is stored sequentially anyway, also in a QList, for mColorRampItemList it should make a difference, though it has to be converted from/to QList to keep API
1 parent 3360b82 commit 9470c36

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed
 

‎src/core/raster/qgscolorrampshader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ QString QgsColorRampShader::colorRampTypeAsQString()
5252

5353
void QgsColorRampShader::setColorRampItemList( const QList<QgsColorRampShader::ColorRampItem>& theList )
5454
{
55-
mColorRampItemList = theList;
55+
mColorRampItemList = theList.toVector();
5656
// Reset the look up table when the color ramp is changed
5757
mLUTInitialized = false;
5858
mLUT.clear();
@@ -236,7 +236,7 @@ bool QgsColorRampShader::shade( double theRedValue, double theGreenValue,
236236

237237
void QgsColorRampShader::legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const
238238
{
239-
QList<QgsColorRampShader::ColorRampItem>::const_iterator colorRampIt = mColorRampItemList.constBegin();
239+
QVector<QgsColorRampShader::ColorRampItem>::const_iterator colorRampIt = mColorRampItemList.constBegin();
240240
for ( ; colorRampIt != mColorRampItemList.constEnd(); ++colorRampIt )
241241
{
242242
symbolItems.push_back( qMakePair( colorRampIt->label, colorRampIt->color ) );

‎src/core/raster/qgscolorrampshader.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ originally part of the larger QgsRasterLayer class
2222
#define QGSCOLORRAMPSHADER_H
2323

2424
#include <QColor>
25-
#include <QMap>
25+
#include <QVector>
2626

2727
#include "qgsrastershaderfunction.h"
2828

@@ -63,7 +63,7 @@ class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction
6363
};
6464

6565
/** \brief Get the custom colormap*/
66-
QList<QgsColorRampShader::ColorRampItem> colorRampItemList() const {return mColorRampItemList;}
66+
QList<QgsColorRampShader::ColorRampItem> colorRampItemList() const {return mColorRampItemList.toList();}
6767

6868
/** \brief Get the color ramp type */
6969
QgsColorRampShader::ColorRamp_TYPE colorRampType() const {return mColorRampType;}
@@ -115,14 +115,14 @@ class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction
115115
* mDiscreteClassification holds if one color is applied for all values
116116
* between two class breaks (true) or if the item values are (linearly)
117117
* interpolated for values between the item values (false)*/
118-
QList<QgsColorRampShader::ColorRampItem> mColorRampItemList;
118+
QVector<QgsColorRampShader::ColorRampItem> mColorRampItemList;
119119

120120
/** \brief The color ramp type */
121121
QgsColorRampShader::ColorRamp_TYPE mColorRampType;
122122

123123
/** Look up table to speed up finding the right color.
124124
* It is initialized on the first call to shade(). */
125-
QList<int> mLUT;
125+
QVector<int> mLUT;
126126
double mLUTOffset;
127127
double mLUTFactor;
128128
bool mLUTInitialized = false;

0 commit comments

Comments
 (0)
Please sign in to comment.