Skip to content

Commit 252dbdc

Browse files
committedFeb 2, 2018
Fix clazy unnecessary unnecessary container allocation warnings
1 parent ef7e7c5 commit 252dbdc

File tree

8 files changed

+29
-27
lines changed

8 files changed

+29
-27
lines changed
 

‎src/analysis/processing/qgsalgorithmrasterlayeruniquevalues.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,10 @@ QVariantMap QgsRasterLayerUniqueValuesReportAlgorithm::processAlgorithm( const Q
176176
out << QObject::tr( "<p>%1: %2</p>\n" ).arg( QObject::tr( "NODATA pixel count" ) ).arg( noDataCount );
177177
out << QString( "<table><tr><td>%1</td><td>%2</td><td>%3 (%4)</td></tr>\n" ).arg( QObject::tr( "Value" ), QObject::tr( "Pixel count" ), QObject::tr( "Area" ), areaUnit );
178178

179-
for ( double key : sortedUniqueValues.keys() )
179+
for ( auto it = sortedUniqueValues.constBegin(); it != sortedUniqueValues.constEnd(); ++it )
180180
{
181-
double area = sortedUniqueValues[key] * pixelArea;
182-
out << QString( "<tr><td>%1</td><td>%2</td><td>%3</td></tr>\n" ).arg( key ).arg( sortedUniqueValues[key] ).arg( QString::number( area, 'g', 16 ) );
181+
double area = it.value() * pixelArea;
182+
out << QString( "<tr><td>%1</td><td>%2</td><td>%3</td></tr>\n" ).arg( it.key() ).arg( it.value() ).arg( QString::number( area, 'g', 16 ) );
183183
}
184184
out << QString( "</table>\n</body></html>" );
185185
outputs.insert( QStringLiteral( "OUTPUT_HTML_FILE" ), outputFile );

‎src/app/layout/qgslayoutlegendwidget.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -739,20 +739,20 @@ void QgsLayoutLegendWidget::mRemoveToolButton_clicked()
739739
nodesWithRemoval[nodeLayer].append( _unfilteredLegendNodeIndex( legendNode ) );
740740
}
741741
}
742-
Q_FOREACH ( QgsLayerTreeLayer *nodeLayer, nodesWithRemoval.keys() )
742+
for ( auto it = nodesWithRemoval.constBegin(); it != nodesWithRemoval.constEnd(); ++it )
743743
{
744-
QList<int> toDelete = nodesWithRemoval[nodeLayer];
744+
QList<int> toDelete = it.value();
745745
std::sort( toDelete.begin(), toDelete.end(), std::greater<int>() );
746-
QList<int> order = QgsMapLayerLegendUtils::legendNodeOrder( nodeLayer );
746+
QList<int> order = QgsMapLayerLegendUtils::legendNodeOrder( it.key() );
747747

748748
Q_FOREACH ( int i, toDelete )
749749
{
750750
if ( i >= 0 && i < order.count() )
751751
order.removeAt( i );
752752
}
753753

754-
QgsMapLayerLegendUtils::setLegendNodeOrder( nodeLayer, order );
755-
mItemTreeView->layerTreeModel()->refreshLayerLegend( nodeLayer );
754+
QgsMapLayerLegendUtils::setLegendNodeOrder( it.key(), order );
755+
mItemTreeView->layerTreeModel()->refreshLayerLegend( it.key() );
756756
}
757757

758758
// then remove layer tree nodes

‎src/core/layout/qgscompositionconverter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,8 +1655,9 @@ bool QgsCompositionConverter::readOldComposerObjectXml( QgsLayoutObject *layoutI
16551655

16561656
void QgsCompositionConverter::readOldDataDefinedPropertyMap( const QDomElement &itemElem, QgsPropertyCollection &dataDefinedProperties )
16571657
{
1658-
QgsPropertiesDefinition::const_iterator i = QgsCompositionConverter::propertyDefinitions().constBegin();
1659-
for ( ; i != QgsCompositionConverter::propertyDefinitions().constEnd(); ++i )
1658+
const QgsPropertiesDefinition defs = QgsCompositionConverter::propertyDefinitions();
1659+
QgsPropertiesDefinition::const_iterator i = defs.constBegin();
1660+
for ( ; i != defs.constEnd(); ++i )
16601661
{
16611662
QString elemName = i.value().name();
16621663
QDomNodeList ddNodeList = itemElem.elementsByTagName( elemName );

‎src/core/qgsauxiliarystorage.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -428,11 +428,11 @@ QgsPropertyDefinition QgsAuxiliaryLayer::propertyDefinitionFromField( const QgsF
428428
if ( origin.compare( "labeling", Qt::CaseInsensitive ) == 0 )
429429
{
430430
const QgsPropertiesDefinition props = QgsPalLayerSettings::propertyDefinitions();
431-
for ( const QgsPropertyDefinition &p : props.values() )
431+
for ( auto it = props.constBegin(); it != props.constEnd(); ++it )
432432
{
433-
if ( p.name().compare( propertyName, Qt::CaseInsensitive ) == 0 )
433+
if ( it.value().name().compare( propertyName, Qt::CaseInsensitive ) == 0 )
434434
{
435-
def = p;
435+
def = it.value();
436436
if ( parts.size() == 3 )
437437
def.setComment( parts[2] );
438438
break;
@@ -442,11 +442,11 @@ QgsPropertyDefinition QgsAuxiliaryLayer::propertyDefinitionFromField( const QgsF
442442
else if ( origin.compare( "symbol", Qt::CaseInsensitive ) == 0 )
443443
{
444444
const QgsPropertiesDefinition props = QgsSymbolLayer::propertyDefinitions();
445-
for ( const QgsPropertyDefinition &p : props.values() )
445+
for ( auto it = props.constBegin(); it != props.constEnd(); ++it )
446446
{
447-
if ( p.name().compare( propertyName, Qt::CaseInsensitive ) == 0 )
447+
if ( it.value().name().compare( propertyName, Qt::CaseInsensitive ) == 0 )
448448
{
449-
def = p;
449+
def = it.value();
450450
if ( parts.size() == 3 )
451451
def.setComment( parts[2] );
452452
break;
@@ -456,11 +456,11 @@ QgsPropertyDefinition QgsAuxiliaryLayer::propertyDefinitionFromField( const QgsF
456456
else if ( origin.compare( "diagram", Qt::CaseInsensitive ) == 0 )
457457
{
458458
const QgsPropertiesDefinition props = QgsDiagramLayerSettings::propertyDefinitions();
459-
for ( const QgsPropertyDefinition &p : props.values() )
459+
for ( auto it = props.constBegin(); it != props.constEnd(); ++it )
460460
{
461-
if ( p.name().compare( propertyName, Qt::CaseInsensitive ) == 0 )
461+
if ( it.value().name().compare( propertyName, Qt::CaseInsensitive ) == 0 )
462462
{
463-
def = p;
463+
def = it.value();
464464
if ( parts.size() == 3 )
465465
def.setComment( parts[2] );
466466
break;

‎src/core/qgsproject.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2414,12 +2414,13 @@ void QgsProject::setTrustLayerMetadata( bool trust )
24142414

24152415
bool QgsProject::saveAuxiliaryStorage( const QString &filename )
24162416
{
2417-
for ( QgsMapLayer *l : mapLayers().values() )
2417+
const QMap<QString, QgsMapLayer *> layers = mapLayers();
2418+
for ( auto it = layers.constBegin(); it != layers.constEnd(); ++it )
24182419
{
2419-
if ( l->type() != QgsMapLayer::VectorLayer )
2420+
if ( it.value()->type() != QgsMapLayer::VectorLayer )
24202421
continue;
24212422

2422-
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( l );
2423+
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( it.value() );
24232424
if ( vl && vl->auxiliaryLayer() )
24242425
{
24252426
vl->auxiliaryLayer()->save();

‎src/gui/layout/qgslayoutmousehandles.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ bool QgsLayoutMouseHandles::selectionRotation( double &rotation ) const
296296
double firstItemRotation = ( *itemIter )->rotation();
297297

298298
//iterate through remaining items, checking if they have same rotation
299-
for ( ++itemIter; itemIter != selectedItems.end(); ++itemIter )
299+
for ( ++itemIter; itemIter != selectedItems.constEnd(); ++itemIter )
300300
{
301301
if ( !qgsDoubleNear( ( *itemIter )->rotation(), firstItemRotation ) )
302302
{

‎src/providers/wcs/qgswcssourceselect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void QgsWCSSourceSelect::populateLayerList()
8787
lItem->setData( 0, Qt::UserRole + 1, "" );
8888

8989
// Make only leaves selectable
90-
if ( !coverageParents.keys( coverage->orderId ).isEmpty() )
90+
if ( coverageParents.contains( coverage->orderId ) )
9191
{
9292
lItem->setFlags( Qt::ItemIsEnabled );
9393
}

‎tests/src/core/testqgsrasterlayer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,9 @@ void TestQgsRasterLayer::populateColorRampShader( QgsColorRampShader *colorRampS
279279

280280
//items to imitate old pseudo color renderer
281281
QList<QgsColorRampShader::ColorRampItem> colorRampItems;
282-
QList<double>::const_iterator value_it = entryValues.begin();
283-
QVector<QColor>::const_iterator color_it = entryColors.begin();
284-
for ( ; value_it != entryValues.end(); ++value_it, ++color_it )
282+
QList<double>::const_iterator value_it = entryValues.constBegin();
283+
QVector<QColor>::const_iterator color_it = entryColors.constBegin();
284+
for ( ; value_it != entryValues.constEnd(); ++value_it, ++color_it )
285285
{
286286
colorRampItems.append( QgsColorRampShader::ColorRampItem( *value_it, *color_it ) );
287287
}

0 commit comments

Comments
 (0)
Please sign in to comment.