Skip to content

Commit

Permalink
Change QList to QVector for speed increase
Browse files Browse the repository at this point in the history
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.
4 changes: 2 additions & 2 deletions src/core/raster/qgscolorrampshader.cpp
Expand Up @@ -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;
mLUT.clear();
Expand Down Expand Up @@ -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 ) );
Expand Down
8 changes: 4 additions & 4 deletions src/core/raster/qgscolorrampshader.h
Expand Up @@ -22,7 +22,7 @@ originally part of the larger QgsRasterLayer class
#define QGSCOLORRAMPSHADER_H

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

#include "qgsrastershaderfunction.h"

Expand Down Expand Up @@ -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;}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9470c36

Please sign in to comment.