Skip to content
Permalink
Browse files

Change a lot of arguments to const references in core/gui

Rationale:
- there was a lot of large objects passed by value, so potentially
there's a speed bump from this
- even for implicitly shared classes like QString/QList there's still
a (small) cost for copying the objects when there's no reason to
- it's the right thing to do!
  • Loading branch information
nyalldawson committed Oct 7, 2015
1 parent 33265e2 commit c49b5b777fdf93ae864486c4ab06b7cae4650dc3
Showing 721 changed files with 2,288 additions and 2,291 deletions.
@@ -5,7 +5,7 @@ class QgsGridFileWriter
%End

public:
QgsGridFileWriter( QgsInterpolator* i, QString outputPath, QgsRectangle extent, int nCols, int nRows, double cellSizeX, double cellSizeY );
QgsGridFileWriter( QgsInterpolator* i, const QString& outputPath, const QgsRectangle& extent, int nCols, int nRows, double cellSizeX, double cellSizeY );
~QgsGridFileWriter();

/** Writes the grid file.
@@ -7,7 +7,7 @@ class QgsPointSample
#include <qgspointsample.h>
%End
public:
QgsPointSample( QgsVectorLayer* inputLayer, const QString& outputLayer, QString nPointsAttribute, QString minDistAttribute = QString() );
QgsPointSample( QgsVectorLayer* inputLayer, const QString& outputLayer, const QString& nPointsAttribute, const QString& minDistAttribute = QString() );
~QgsPointSample();

/** Starts calculation of random points
@@ -16,9 +16,9 @@ class QgsTransectSample
StrataUnits //units are the same as stratum layer
};

QgsTransectSample( QgsVectorLayer* strataLayer, QString strataIdAttribute, QString minDistanceAttribute, QString nPointsAttribute,
QgsTransectSample( QgsVectorLayer* strataLayer, const QString& strataIdAttribute, const QString& minDistanceAttribute, const QString& nPointsAttribute,
DistanceUnits minDistUnits, QgsVectorLayer* baselineLayer, bool shareBaseline,
QString baselineStrataId, const QString& outputPointLayer, const QString& outputLineLayer, const QString& usedBaselineLayer,
const QString& baselineStrataId, const QString& outputPointLayer, const QString& outputLineLayer, const QString& usedBaselineLayer,
double minTransectLength = 0.0, double baselineBufferDistance = -1.0, double baselineSimplificationTolerance = -1.0 );
~QgsTransectSample();

@@ -31,7 +31,7 @@ class QgsZonalStatistics
typedef QFlags<QgsZonalStatistics::Statistic> Statistics;

QgsZonalStatistics( QgsVectorLayer* polygonLayer, const QString& rasterFile, const QString& attributePrefix = "", int rasterBand = 1,
QgsZonalStatistics::Statistics stats = QgsZonalStatistics::Statistics( QgsZonalStatistics::Count | QgsZonalStatistics::Sum | QgsZonalStatistics::Mean) );
const QgsZonalStatistics::Statistics& stats = QgsZonalStatistics::Statistics( QgsZonalStatistics::Count | QgsZonalStatistics::Sum | QgsZonalStatistics::Mean) );
~QgsZonalStatistics();

/** Starts the calculation
@@ -46,13 +46,13 @@ class QgsAuthCertUtils
static QString getSslProtocolName( QSsl::SslProtocol protocol );


static QMap< QString, QSslCertificate> mapDigestToCerts( QList<QSslCertificate> certs );
static QMap< QString, QSslCertificate> mapDigestToCerts( const QList<QSslCertificate>& certs );


// static QMap< QString, QList<QSslCertificate> > certsGroupedByOrg( QList<QSslCertificate> certs );


static QMap< QString, QgsAuthConfigSslServer> mapDigestToSslConfigs( QList<QgsAuthConfigSslServer> configs );
static QMap< QString, QgsAuthConfigSslServer> mapDigestToSslConfigs( const QList<QgsAuthConfigSslServer>& configs );


// static QMap< QString, QList<QgsAuthConfigSslServer> > sslConfigsGroupedByOrg( QList<QgsAuthConfigSslServer> configs );
@@ -5,7 +5,7 @@ class QgsAuthMethodConfig
%End
public:

QgsAuthMethodConfig( QString method = QString(), int version = 0 );
QgsAuthMethodConfig( const QString& method = QString(), int version = 0 );

QgsAuthMethodConfig( const QgsAuthMethodConfig& methodconfig );

@@ -25,7 +25,7 @@ class QgsAuthMethodConfig
void setUri( const QString& uri );

QString method() const;
void setMethod( QString method );
void setMethod( const QString& method );

int version() const;
void setVersion( int version );
@@ -36,14 +36,14 @@ class QgsAuthMethodConfig
void loadConfigString( const QString& configstr );

QgsStringMap configMap() const;
void setConfigMap( QgsStringMap map );
void setConfigMap( const QgsStringMap& map );

void setConfig( const QString &key, const QString &value );
void setConfigList( const QString &key, const QStringList &value );

int removeConfig( const QString &key );

QString config( const QString &key , const QString defaultvalue = QString() ) const;
QString config( const QString &key, const QString& defaultvalue = QString() ) const;

QStringList configList( const QString &key ) const;

@@ -7,9 +7,9 @@ class QgsAuthCrypto
public:
static bool isDisabled();

static const QString encrypt( QString pass, QString cipheriv, QString text );
static const QString encrypt( const QString& pass, const QString& cipheriv, const QString& text );

static const QString decrypt( QString pass, QString cipheriv, QString text );
static const QString decrypt( const QString& pass, const QString& cipheriv, const QString& text );

static void passwordKeyHash( const QString &pass,
QString *salt,
@@ -24,7 +24,7 @@ class QgsAuthManager : QObject

const QString authDbServersTable() const;

bool init( QString pluginPath = QString::null );
bool init( const QString& pluginPath = QString::null );

bool isDisabled() const;

@@ -107,9 +107,9 @@ class QgsAuthManager : QObject

////////////////// Generic settings ///////////////////////

bool storeAuthSetting( const QString& key, QVariant value, bool encrypt = false );
bool storeAuthSetting( const QString& key, const QVariant& value, bool encrypt = false );

QVariant getAuthSetting( const QString& key, QVariant defaultValue = QVariant(), bool decrypt = false );
QVariant getAuthSetting( const QString& key, const QVariant& defaultValue = QVariant(), bool decrypt = false );

bool existsAuthSetting( const QString& key );

@@ -50,8 +50,8 @@ class QgsAuthMethod : QObject

void setVersion( int version );

void setExpansions( QgsAuthMethod::Expansions expansions );
void setDataProviders( QStringList dataproviders );
void setExpansions( const QgsAuthMethod::Expansions& expansions );
void setDataProviders( const QStringList& dataproviders );
};

typedef QHash<QString, QgsAuthMethod*> QgsAuthMethodsMap;
@@ -137,7 +137,7 @@ public:
QString featureFilterErrorString() const;

QString sortKeyAttributeName() const;
void setSortKeyAttributeName( QString fieldName );
void setSortKeyAttributeName( const QString& fieldName );

/** Returns the current list of predefined scales for the atlas. This is used
* for maps which are set to the predefined atlas scaling mode.
@@ -215,7 +215,7 @@ class QgsComposerAttributeTable : QgsComposerTable
* @deprecated use QgsComposerTable::columns() instead
* @note not available in python bindings
*/
// void setSortAttributes( const QList<QPair<int, bool> > att ) /Deprecated/;
// void setSortAttributes( const QList<QPair<int, bool> >& att ) /Deprecated/;

/** Returns the attributes used to sort the table's features.
* @returns a QList of integer/bool pairs, where the integer refers to the attribute index and
@@ -102,7 +102,7 @@ class QgsComposerAttributeTableV2 : QgsComposerTableV2
* @see setSource
* @note only used if table source is set to RelationChildren
*/
void setRelationId( const QString relationId );
void setRelationId( const QString& relationId );

/** Returns the relation id which the table displays child features from
* @returns relation id
@@ -63,7 +63,7 @@ class QgsComposerHtml: QgsComposerMultiFrame
* @see loadHtml
* @note added in 2.5
*/
void setHtml( const QString html );
void setHtml( const QString& html );

/** Returns the HTML source displayed in the item if the item is using
* the QgsComposerHtml::ManualHtml mode.
@@ -144,7 +144,7 @@ class QgsComposerHtml: QgsComposerMultiFrame
* @see loadHtml
* @note added in 2.5
*/
void setUserStylesheet( const QString stylesheet );
void setUserStylesheet( const QString& stylesheet );

/** Returns the user stylesheet CSS rules used while rendering the HTML content. These
* overriding the styles specified within the HTML source.
@@ -724,7 +724,7 @@ class QgsComposerItem : QgsComposerObject, QGraphicsRectItem
* @param rotation the rotation in degrees to be applied to the rectangle
* @deprecated use QgsComposerUtils::largestRotatedRectWithinBounds instead
*/
QRectF largestRotatedRectWithinBounds( QRectF originalRect, QRectF boundsRect, double rotation ) const /Deprecated/;
QRectF largestRotatedRectWithinBounds( const QRectF& originalRect, const QRectF& boundsRect, double rotation ) const /Deprecated/;

/** Calculates corner point after rotation and scaling
* @deprecated will be removed in QGIS 3.0
@@ -31,12 +31,12 @@ class QgsComposerLabel : QgsComposerItem
/** Sets the current feature, the current layer and a list of local variable substitutions for evaluating expressions
* @deprecated use atlas features and setSubstitutions() instead
*/
void setExpressionContext( QgsFeature* feature, QgsVectorLayer* layer, QMap<QString, QVariant> substitutions = QMap<QString, QVariant>() ) /Deprecated/;
void setExpressionContext( QgsFeature* feature, QgsVectorLayer* layer, const QMap<QString, QVariant>& substitutions = QMap<QString, QVariant>() ) /Deprecated/;

/** Sets the list of local variable substitutions for evaluating expressions in label text.
* @note added in QGIS 2.12
*/
void setSubstitutions( QMap<QString, QVariant> substitutions = QMap<QString, QVariant>() );
void setSubstitutions( const QMap<QString, QVariant>& substitutions = QMap<QString, QVariant>() );

QFont font() const;
void setFont( const QFont& f );
@@ -86,7 +86,7 @@ class QgsComposerLegend : QgsComposerItem
QgsComposerLegendStyle & rstyle( QgsComposerLegendStyle::Style s );
/** Returns style */
QgsComposerLegendStyle style( QgsComposerLegendStyle::Style s ) const;
void setStyle( QgsComposerLegendStyle::Style s, const QgsComposerLegendStyle style );
void setStyle( QgsComposerLegendStyle::Style s, const QgsComposerLegendStyle& style );

QFont styleFont( QgsComposerLegendStyle::Style s ) const;
/** Set style font */
@@ -111,7 +111,7 @@ class QgsComposerLayerItem : QgsComposerLegendItem
void setShowFeatureCount( bool show );
bool showFeatureCount() const;

void setDefaultStyle();
void setDefaultStyle( double scaleDenominator = -1, const QString& rule = "" );
};

class QgsComposerGroupItem : QgsComposerLegendItem
@@ -34,15 +34,15 @@ class QgsComposerLegendStyle
// set all margins
void setMargin( double margin );

void writeXML( QString name, QDomElement& elem, QDomDocument & doc ) const;
void writeXML( const QString& name, QDomElement& elem, QDomDocument & doc ) const;

void readXML( const QDomElement& elem, const QDomDocument& doc );

/** Get name for style, used in project file */
static QString styleName( Style s );

/** Get style from name, used in project file */
static Style styleFromName( QString styleName );
static Style styleFromName( const QString& styleName );

/** Get style label, translated, used in UI */
static QString styleLabel( Style s );
@@ -668,7 +668,7 @@ class QgsComposerMapGrid : QgsComposerMapItem
* @see frameSideFlags
* @see testFrameSideFlag
*/
void setFrameSideFlags( const FrameSideFlags flags );
void setFrameSideFlags( const FrameSideFlags& flags );

/** Sets whether the grid frame is drawn for a certain side of the map item.
* @param flag flag for grid frame side
@@ -242,7 +242,7 @@ class QgsComposerPicture: QgsComposerItem
* @see pictureExpression
* @deprecated use QgsComposerObject::dataDefinedProperty( QgsComposerObject::PictureSource ) instead
*/
virtual void setPictureExpression( QString expression ) /Deprecated/;
virtual void setPictureExpression( const QString& expression ) /Deprecated/;

/** Recalculates the source image (if using an expression for picture's source)
* and reloads and redraws the picture.
@@ -197,7 +197,7 @@ class QgsComposerTable: QgsComposerItem
* @note added in 2.3
* @see columns
*/
void setColumns( QList<QgsComposerTableColumn*> columns );
void setColumns( const QList<QgsComposerTableColumn*>& columns );

public slots:

@@ -58,7 +58,7 @@ class QgsComposerTableColumn: QObject
* @note added in 2.3
* @see heading
*/
void setHeading( QString heading );
void setHeading( const QString& heading );

/** Returns the horizontal alignment for a column, which controls the alignment
* used for drawing column values within cells.
@@ -112,7 +112,7 @@ class QgsComposerTableColumn: QObject
* @note only applicable when used in a QgsComposerAttributeTable
* @see attribute
*/
void setAttribute( QString attribute );
void setAttribute( const QString& attribute );

/** Returns the sort order for the column. This property is only used when the column
* is part of a QgsComposerAttributeTable and when sortByRank is > 0.
@@ -154,7 +154,7 @@ class QgsComposerTableV2: QgsComposerMultiFrame
* @see emptyTableMessage
* @see setEmptyTableBehaviour
*/
void setEmptyTableMessage( const QString message );
void setEmptyTableMessage( const QString& message );

/** Returns the message for empty tables with no content rows. This message
* is displayed in the table body if the empty table behaviour is
@@ -351,7 +351,7 @@ class QgsComposerTableV2: QgsComposerMultiFrame
* @param columns list of QgsComposerTableColumns to show in table
* @see columns
*/
void setColumns( QgsComposerTableColumns columns );
void setColumns( const QgsComposerTableColumns& columns );

/** Sets the cell style for a cell group.
* @param group group to set style for
@@ -92,15 +92,15 @@ class QgsComposerUtils
* @param ok will be true if string could be decoded
* @returns decoded paper orientation
*/
static QgsComposition::PaperOrientation decodePaperOrientation( const QString orientationString, bool &ok );
static QgsComposition::PaperOrientation decodePaperOrientation( const QString& orientationString, bool &ok );

/** Decodes a string representing a preset page size
* @param presetString string to decode
* @param width double for decoded paper width
* @param height double for decoded paper height
* @returns true if string could be decoded successfully
*/
static bool decodePresetPaperSize( const QString presetString, double &width, double &height );
static bool decodePresetPaperSize( const QString& presetString, double &width, double &height );

/** Reads all data defined properties from xml
* @param itemElem dom element containing data defined properties
@@ -364,12 +364,12 @@ class QgsComposition : QGraphicsScene
retrieve.
@return QgsComposerItem pointer or 0 pointer if no such item exists.
*/
const QgsComposerItem* getComposerItemById( const QString theId ) const;
const QgsComposerItem* getComposerItemById( const QString& theId ) const;

/** Returns a composer item given its unique identifier.
@param theUuid A QString representing the UUID of the item to
**/
const QgsComposerItem* getComposerItemByUuid( const QString theUuid ) const;
const QgsComposerItem* getComposerItemByUuid( const QString& theUuid ) const;

int printResolution() const;
void setPrintResolution( const int dpi );
@@ -27,7 +27,7 @@ class QgsLegendModel : QStandardItemModel
* @deprecated in 2.6
*/
void setLayerSetAndGroups( const QStringList& layerIds, const QList< QPair< QString, QList<QString> > >& groupInfo ) /Deprecated/;
void setLayerSet( const QStringList& layerIds, double scaleDenominator = -1, QString rule = "" );
void setLayerSet( const QStringList& layerIds, double scaleDenominator = -1, const QString& rule = "" );
/** Adds a group
@param text name of group (defaults to translation of "Group")
@param position insertion position (toplevel position (or -1 if it should be placed at the end of the legend).
@@ -41,7 +41,7 @@ class QgsLegendModel : QStandardItemModel
/** Updates the whole symbology of a layer*/
void updateLayer( QStandardItem* layerItem );
/** Tries to update a single classification item*/
void updateVectorV2ClassificationItem( QStandardItem* classificationItem, QgsSymbolV2* symbol, QString itemText );
void updateVectorV2ClassificationItem( QStandardItem* classificationItem, QgsSymbolV2* symbol, const QString& itemText );

void updateRasterClassificationItem( QStandardItem* classificationItem );

@@ -70,7 +70,7 @@ class QgsLegendModel : QStandardItemModel

public slots:
void removeLayer( const QString& layerId );
void addLayer( QgsMapLayer* theMapLayer, double scaleDenominator = -1, QString rule = "", QStandardItem* parentItem = 0 );
void addLayer( QgsMapLayer* theMapLayer, double scaleDenominator = -1, const QString& rule = "", QStandardItem* parentItem = 0 );

signals:
void layersChanged();
@@ -32,7 +32,7 @@ class QgsDxfExport
~QgsDxfExport();

void addLayers( const QList< QPair<QgsVectorLayer *, int > > &layers );
int writeToFile( QIODevice *d, QString codec ); //maybe add progress dialog? other parameters (e.g. scale, dpi)?
int writeToFile( QIODevice *d, const QString& codec ); //maybe add progress dialog? other parameters (e.g. scale, dpi)?

void setSymbologyScaleDenominator( double d );
double symbologyScaleDenominator() const;
@@ -42,7 +42,7 @@ class QgsCurvePolygonV2: public QgsSurfaceV2
/** Sets exterior ring (takes ownership)*/
void setExteriorRing( QgsCurveV2* ring /Transfer/ );
/** Sets interior rings (takes ownership)*/
void setInteriorRings( QList<QgsCurveV2*> rings );
void setInteriorRings( const QList<QgsCurveV2*>& rings );
void addInteriorRing( QgsCurveV2* ring /Transfer/ );
/** Removes ring. Exterior ring is 0, first interior ring 1, ...*/
bool removeInteriorRing( int nr );
@@ -72,7 +72,7 @@ class QgsGeometry
bool isEmpty() const;

/** Creates a new geometry from a WKT string */
static QgsGeometry* fromWkt( QString wkt ) /Factory/;
static QgsGeometry* fromWkt( const QString& wkt ) /Factory/;
/** Creates a new geometry from a QgsPoint object*/
static QgsGeometry* fromPoint( const QgsPoint& point ) /Factory/;
/** Creates a new geometry from a QgsMultiPoint object */
@@ -531,8 +531,8 @@ class QgsGeometry
{
public:
Error();
Error( QString m );
Error( QString m, const QgsPoint& p );
Error( const QString& m );
Error( const QString& m, const QgsPoint& p );

QString what();
QgsPoint where();

0 comments on commit c49b5b7

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