Skip to content
Browse files
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
  • Loading branch information
pierstitus committed May 6, 2016
1 parent 3360b82 commit 9470c36
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
@@ -52,7 +52,7 @@ QString QgsColorRampShader::colorRampTypeAsQString()

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

void QgsColorRampShader::legendSymbologyItems( QList< QPair< QString, QColor > >& symbolItems ) const
QList<QgsColorRampShader::ColorRampItem>::const_iterator colorRampIt = mColorRampItemList.constBegin();
QVector<QgsColorRampShader::ColorRampItem>::const_iterator colorRampIt = mColorRampItemList.constBegin();
for ( ; colorRampIt != mColorRampItemList.constEnd(); ++colorRampIt )
symbolItems.push_back( qMakePair( colorRampIt->label, colorRampIt->color ) );
@@ -22,7 +22,7 @@ originally part of the larger QgsRasterLayer class

#include <QColor>
#include <QMap>
#include <QVector>

#include "qgsrastershaderfunction.h"

@@ -63,7 +63,7 @@ class CORE_EXPORT QgsColorRampShader : public QgsRasterShaderFunction

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

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

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

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

0 comments on commit 9470c36

Please sign in to comment.