Skip to content

Commit

Permalink
Remove redundant qgis::as_const implementation, move to c++17 std::as…
Browse files Browse the repository at this point in the history
…_const
  • Loading branch information
nyalldawson committed Mar 20, 2021
1 parent 98ebd40 commit 876ee57
Show file tree
Hide file tree
Showing 320 changed files with 1,153 additions and 976 deletions.
16 changes: 8 additions & 8 deletions src/3d/qgs3dmapscene.cpp
Expand Up @@ -250,7 +250,7 @@ int Qgs3DMapScene::terrainPendingJobsCount() const
int Qgs3DMapScene::totalPendingJobsCount() const
{
int count = 0;
for ( QgsChunkedEntity *entity : qgis::as_const( mChunkEntities ) )
for ( QgsChunkedEntity *entity : std::as_const( mChunkEntities ) )
count += entity->pendingJobsCount();
return count;
}
Expand Down Expand Up @@ -295,7 +295,7 @@ void Qgs3DMapScene::onLayerEntityPickedObject( Qt3DRender::QPickEvent *pickEvent
if ( !vlayer )
return;

for ( Qgs3DMapScenePickHandler *pickHandler : qgis::as_const( mPickHandlers ) )
for ( Qgs3DMapScenePickHandler *pickHandler : std::as_const( mPickHandlers ) )
{
pickHandler->handlePickOnVectorLayer( vlayer, fid, pickEvent->worldIntersection(), pickEvent );
}
Expand Down Expand Up @@ -383,7 +383,7 @@ void addQLayerComponentsToHierarchy( Qt3DCore::QEntity *entity, const QVector<Qt
void Qgs3DMapScene::updateScene()
{
QgsEventTracing::addEvent( QgsEventTracing::Instant, QStringLiteral( "3D" ), QStringLiteral( "Update Scene" ) );
for ( QgsChunkedEntity *entity : qgis::as_const( mChunkEntities ) )
for ( QgsChunkedEntity *entity : std::as_const( mChunkEntities ) )
{
if ( entity->isEnabled() )
entity->update( _sceneState( mCameraController ) );
Expand Down Expand Up @@ -447,7 +447,7 @@ bool Qgs3DMapScene::updateCameraNearFarPlanes()

// Also involve all the other chunked entities to make sure that they will not get
// clipped by the near or far plane
for ( QgsChunkedEntity *e : qgis::as_const( mChunkEntities ) )
for ( QgsChunkedEntity *e : std::as_const( mChunkEntities ) )
{
if ( e != mTerrain )
_updateNearFarPlane( e->activeNodes(), viewMatrix, fnear, ffar );
Expand Down Expand Up @@ -485,7 +485,7 @@ void Qgs3DMapScene::onFrameTriggered( float dt )
{
mCameraController->frameTriggered( dt );

for ( QgsChunkedEntity *entity : qgis::as_const( mChunkEntities ) )
for ( QgsChunkedEntity *entity : std::as_const( mChunkEntities ) )
{
if ( entity->isEnabled() && entity->needsUpdate() )
{
Expand Down Expand Up @@ -585,10 +585,10 @@ void Qgs3DMapScene::onBackgroundColorChanged()

void Qgs3DMapScene::updateLights()
{
for ( Qt3DCore::QEntity *entity : qgis::as_const( mLightEntities ) )
for ( Qt3DCore::QEntity *entity : std::as_const( mLightEntities ) )
entity->deleteLater();
mLightEntities.clear();
for ( Qt3DCore::QEntity *entity : qgis::as_const( mLightOriginEntities ) )
for ( Qt3DCore::QEntity *entity : std::as_const( mLightOriginEntities ) )
entity->deleteLater();
mLightOriginEntities.clear();

Expand Down Expand Up @@ -956,7 +956,7 @@ void Qgs3DMapScene::updateSceneState()
return;
}

for ( QgsChunkedEntity *entity : qgis::as_const( mChunkEntities ) )
for ( QgsChunkedEntity *entity : std::as_const( mChunkEntities ) )
{
if ( entity->isEnabled() && entity->pendingJobsCount() > 0 )
{
Expand Down
4 changes: 2 additions & 2 deletions src/3d/qgs3dmapsettings.cpp
Expand Up @@ -337,15 +337,15 @@ QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteCon
elemTerrain.setAttribute( QStringLiteral( "show-labels" ), mShowLabels ? 1 : 0 );

QDomElement elemPointLights = doc.createElement( QStringLiteral( "point-lights" ) );
for ( const QgsPointLightSettings &pointLight : qgis::as_const( mPointLights ) )
for ( const QgsPointLightSettings &pointLight : std::as_const( mPointLights ) )
{
QDomElement elemPointLight = pointLight.writeXml( doc );
elemPointLights.appendChild( elemPointLight );
}
elem.appendChild( elemPointLights );

QDomElement elemDirectionalLights = doc.createElement( QStringLiteral( "directional-lights" ) );
for ( const QgsDirectionalLightSettings &directionalLight : qgis::as_const( mDirectionalLights ) )
for ( const QgsDirectionalLightSettings &directionalLight : std::as_const( mDirectionalLights ) )
{
QDomElement elemDirectionalLight = directionalLight.writeXml( doc );
elemDirectionalLights.appendChild( elemDirectionalLight );
Expand Down
2 changes: 1 addition & 1 deletion src/3d/qgslayoutitem3dmap.cpp
Expand Up @@ -62,7 +62,7 @@ void QgsLayoutItem3DMap::assignFreeId()

int maxId = -1;
bool used = false;
for ( QgsLayoutItem3DMap *map : qgis::as_const( mapsList ) )
for ( QgsLayoutItem3DMap *map : std::as_const( mapsList ) )
{
if ( map == this )
continue;
Expand Down
16 changes: 8 additions & 8 deletions src/3d/qgsrulebased3drenderer.cpp
Expand Up @@ -107,7 +107,7 @@ void QgsRuleBased3DRenderer::Rule::initFilter()
void QgsRuleBased3DRenderer::Rule::updateElseRules()
{
mElseRules.clear();
for ( Rule *rule : qgis::as_const( mChildren ) )
for ( Rule *rule : std::as_const( mChildren ) )
{
if ( rule->isElse() )
mElseRules << rule;
Expand Down Expand Up @@ -143,7 +143,7 @@ const QgsRuleBased3DRenderer::Rule *QgsRuleBased3DRenderer::Rule::findRuleByKey(
if ( key == mRuleKey )
return this;

for ( Rule *rule : qgis::as_const( mChildren ) )
for ( Rule *rule : std::as_const( mChildren ) )
{
const Rule *r = rule->findRuleByKey( key );
if ( r )
Expand All @@ -157,7 +157,7 @@ QgsRuleBased3DRenderer::Rule *QgsRuleBased3DRenderer::Rule::findRuleByKey( const
if ( key == mRuleKey )
return this;

for ( Rule *rule : qgis::as_const( mChildren ) )
for ( Rule *rule : std::as_const( mChildren ) )
{
Rule *r = rule->findRuleByKey( key );
if ( r )
Expand All @@ -172,7 +172,7 @@ QgsRuleBased3DRenderer::Rule *QgsRuleBased3DRenderer::Rule::clone() const
Rule *newrule = new Rule( symbol, mFilterExp, mDescription );
newrule->setActive( mIsActive );
// clone children
for ( Rule *rule : qgis::as_const( mChildren ) )
for ( Rule *rule : std::as_const( mChildren ) )
newrule->appendChild( rule->clone() );
return newrule;
}
Expand Down Expand Up @@ -258,7 +258,7 @@ void QgsRuleBased3DRenderer::Rule::createHandlers( QgsVectorLayer *layer, QgsRul
}

// call recursively
for ( Rule *rule : qgis::as_const( mChildren ) )
for ( Rule *rule : std::as_const( mChildren ) )
{
rule->createHandlers( layer, handlers );
}
Expand All @@ -284,7 +284,7 @@ void QgsRuleBased3DRenderer::Rule::prepare( const Qgs3DRenderContext &context, Q
}

// call recursively
for ( Rule *rule : qgis::as_const( mChildren ) )
for ( Rule *rule : std::as_const( mChildren ) )
{
rule->prepare( context, attributeNames, handlers );
}
Expand All @@ -307,7 +307,7 @@ QgsRuleBased3DRenderer::Rule::RegisterResult QgsRuleBased3DRenderer::Rule::regis
bool willRegisterSomething = false;

// call recursively
for ( Rule *rule : qgis::as_const( mChildren ) )
for ( Rule *rule : std::as_const( mChildren ) )
{
// Don't process else rules yet
if ( !rule->isElse() )
Expand All @@ -322,7 +322,7 @@ QgsRuleBased3DRenderer::Rule::RegisterResult QgsRuleBased3DRenderer::Rule::regis
// If none of the rules passed then we jump into the else rules and process them.
if ( !willRegisterSomething )
{
for ( Rule *rule : qgis::as_const( mElseRules ) )
for ( Rule *rule : std::as_const( mElseRules ) )
{
registered |= rule->registerFeature( feature, context, handlers ) != Filtered;
}
Expand Down
4 changes: 2 additions & 2 deletions src/3d/symbols/qgslinevertexdata_p.cpp
Expand Up @@ -46,7 +46,7 @@ QByteArray QgsLineVertexData::createVertexBuffer()
vertexBufferData.resize( vertices.size() * 3 * sizeof( float ) );
float *rawVertexArray = reinterpret_cast<float *>( vertexBufferData.data() );
int idx = 0;
for ( const auto &v : qgis::as_const( vertices ) )
for ( const auto &v : std::as_const( vertices ) )
{
rawVertexArray[idx++] = v.x();
rawVertexArray[idx++] = v.y();
Expand All @@ -61,7 +61,7 @@ QByteArray QgsLineVertexData::createIndexBuffer()
indexBufferData.resize( indexes.size() * sizeof( int ) );
unsigned int *rawIndexArray = reinterpret_cast<unsigned int *>( indexBufferData.data() );
int idx = 0;
for ( unsigned int indexVal : qgis::as_const( indexes ) )
for ( unsigned int indexVal : std::as_const( indexes ) )
{
rawIndexArray[idx++] = indexVal;
}
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/interpolation/qgsidwinterpolator.cpp
Expand Up @@ -34,7 +34,7 @@ int QgsIDWInterpolator::interpolatePoint( double x, double y, double &result, Qg
double sumCounter = 0;
double sumDenominator = 0;

for ( const QgsInterpolatorVertexData &vertex : qgis::as_const( mCachedBaseData ) )
for ( const QgsInterpolatorVertexData &vertex : std::as_const( mCachedBaseData ) )
{
double distance = std::sqrt( ( vertex.x - x ) * ( vertex.x - x ) + ( vertex.y - y ) * ( vertex.y - y ) );
if ( qgsDoubleNear( distance, 0.0 ) )
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/interpolation/qgsinterpolator.cpp
Expand Up @@ -43,7 +43,7 @@ QgsInterpolator::Result QgsInterpolator::cacheBaseData( QgsFeedback *feedback )

double layerStep = !mLayerData.empty() ? 100.0 / mLayerData.count() : 1;
int layerCount = 0;
for ( const LayerData &layer : qgis::as_const( mLayerData ) )
for ( const LayerData &layer : std::as_const( mLayerData ) )
{
if ( feedback && feedback->isCanceled() )
return Canceled;
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/interpolation/qgstininterpolator.cpp
Expand Up @@ -96,7 +96,7 @@ void QgsTinInterpolator::initialize()
int nProcessedFeatures = 0;
if ( mFeedback )
{
for ( const LayerData &layer : qgis::as_const( mLayerData ) )
for ( const LayerData &layer : std::as_const( mLayerData ) )
{
if ( layer.source )
{
Expand All @@ -108,7 +108,7 @@ void QgsTinInterpolator::initialize()
const QgsCoordinateReferenceSystem crs = !mLayerData.empty() ? mLayerData.at( 0 ).source->sourceCrs() : QgsCoordinateReferenceSystem();

QgsFeature f;
for ( const LayerData &layer : qgis::as_const( mLayerData ) )
for ( const LayerData &layer : std::as_const( mLayerData ) )
{
if ( layer.source )
{
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/network/qgsvectorlayerdirector.cpp
Expand Up @@ -216,7 +216,7 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
else if ( QgsWkbTypes::flatType( feature.geometry().wkbType() ) == QgsWkbTypes::LineString )
mpl.push_back( feature.geometry().asPolyline() );

for ( const QgsPolylineXY &line : qgis::as_const( mpl ) )
for ( const QgsPolylineXY &line : std::as_const( mpl ) )
{
QgsPointXY pt1, pt2;
bool isFirstPoint = true;
Expand Down Expand Up @@ -339,7 +339,7 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
else if ( QgsWkbTypes::flatType( feature.geometry().wkbType() ) == QgsWkbTypes::LineString )
mpl.push_back( feature.geometry().asPolyline() );

for ( const QgsPolylineXY &line : qgis::as_const( mpl ) )
for ( const QgsPolylineXY &line : std::as_const( mpl ) )
{
QgsPointXY pt1, pt2;

Expand Down
4 changes: 2 additions & 2 deletions src/analysis/processing/qgsalgorithmaddincrementalfield.cpp
Expand Up @@ -131,7 +131,7 @@ QgsFeatureList QgsAddIncrementalFieldAlgorithm::processFeature( const QgsFeature
{
if ( !mGroupedFieldNames.empty() && mGroupedFields.empty() )
{
for ( const QString &field : qgis::as_const( mGroupedFieldNames ) )
for ( const QString &field : std::as_const( mGroupedFieldNames ) )
{
int idx = mFields.lookupField( field );
if ( idx >= 0 )
Expand All @@ -150,7 +150,7 @@ QgsFeatureList QgsAddIncrementalFieldAlgorithm::processFeature( const QgsFeature
{
QgsAttributes groupAttributes;
groupAttributes.reserve( mGroupedFields.size() );
for ( int index : qgis::as_const( mGroupedFields ) )
for ( int index : std::as_const( mGroupedFields ) )
{
groupAttributes << f.attribute( index );
}
Expand Down
6 changes: 3 additions & 3 deletions src/analysis/processing/qgsalgorithmcategorizeusingstyle.cpp
Expand Up @@ -217,7 +217,7 @@ QVariantMap QgsCategorizeUsingStyleAlgorithm::processAlgorithm( const QVariantMa
QgsCategoryList cats;
cats.reserve( uniqueVals.count() );
std::unique_ptr< QgsSymbol > defaultSymbol( QgsSymbol::defaultSymbol( mLayerGeometryType ) );
for ( const QVariant &val : qgis::as_const( sortedUniqueVals ) )
for ( const QVariant &val : std::as_const( sortedUniqueVals ) )
{
cats.append( QgsRendererCategory( val, defaultSymbol->clone(), val.toString() ) );
}
Expand Down Expand Up @@ -245,7 +245,7 @@ QVariantMap QgsCategorizeUsingStyleAlgorithm::processAlgorithm( const QVariantMa
{
feedback->pushInfo( QObject::tr( "\n%1 categories could not be matched:" ).arg( unmatchedCategories.count() ) );
std::sort( unmatchedCategories.begin(), unmatchedCategories.end() );
for ( const QVariant &cat : qgis::as_const( unmatchedCategories ) )
for ( const QVariant &cat : std::as_const( unmatchedCategories ) )
{
feedback->pushInfo( QStringLiteral( "∙ “%1”" ).arg( cat.toString() ) );
if ( nonMatchingCategoriesSink )
Expand All @@ -261,7 +261,7 @@ QVariantMap QgsCategorizeUsingStyleAlgorithm::processAlgorithm( const QVariantMa
{
feedback->pushInfo( QObject::tr( "\n%1 symbols in style were not matched:" ).arg( unmatchedSymbols.count() ) );
std::sort( unmatchedSymbols.begin(), unmatchedSymbols.end() );
for ( const QString &name : qgis::as_const( unmatchedSymbols ) )
for ( const QString &name : std::as_const( unmatchedSymbols ) )
{
feedback->pushInfo( QStringLiteral( "∙ “%1”" ).arg( name ) );
if ( nonMatchingSymbolsSink )
Expand Down
10 changes: 5 additions & 5 deletions src/analysis/processing/qgsalgorithmcellstatistics.cpp
Expand Up @@ -104,7 +104,7 @@ bool QgsCellStatisticsAlgorithmBase::prepareAlgorithm( const QVariantMap &parame
//determine output raster data type
//initially raster data type to most primitive data type that is possible
mDataType = Qgis::Byte;
for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : qgis::as_const( mInputs ) )
for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : std::as_const( mInputs ) )
{
for ( int band : i.bands )
{
Expand Down Expand Up @@ -275,7 +275,7 @@ void QgsCellStatisticsAlgorithm::processRasterStack( QgsProcessingFeedback *feed
while ( outputIter.readNextRasterPart( 1, iterCols, iterRows, outputBlock, iterLeft, iterTop, &blockExtent ) )
{
std::vector< std::unique_ptr< QgsRasterBlock > > inputBlocks;
for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : qgis::as_const( mInputs ) )
for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : std::as_const( mInputs ) )
{
if ( feedback->isCanceled() )
break; //in case some slow data sources are loaded
Expand Down Expand Up @@ -452,7 +452,7 @@ void QgsCellStatisticsPercentileAlgorithm::processRasterStack( QgsProcessingFeed
while ( outputIter.readNextRasterPart( 1, iterCols, iterRows, outputBlock, iterLeft, iterTop, &blockExtent ) )
{
std::vector< std::unique_ptr< QgsRasterBlock > > inputBlocks;
for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : qgis::as_const( mInputs ) )
for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : std::as_const( mInputs ) )
{
if ( feedback->isCanceled() )
break; //in case some slow data sources are loaded
Expand Down Expand Up @@ -590,7 +590,7 @@ void QgsCellStatisticsPercentRankFromValueAlgorithm::processRasterStack( QgsProc
while ( outputIter.readNextRasterPart( 1, iterCols, iterRows, outputBlock, iterLeft, iterTop, &blockExtent ) )
{
std::vector< std::unique_ptr< QgsRasterBlock > > inputBlocks;
for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : qgis::as_const( mInputs ) )
for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : std::as_const( mInputs ) )
{
if ( feedback->isCanceled() )
break; //in case some slow data sources are loaded
Expand Down Expand Up @@ -735,7 +735,7 @@ void QgsCellStatisticsPercentRankFromRasterAlgorithm::processRasterStack( QgsPro
std::unique_ptr< QgsRasterBlock > valueBlock( mValueRasterInterface->block( mValueRasterBand, blockExtent, iterCols, iterRows ) );

std::vector< std::unique_ptr< QgsRasterBlock > > inputBlocks;
for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : qgis::as_const( mInputs ) )
for ( const QgsRasterAnalysisUtils::RasterLogicInput &i : std::as_const( mInputs ) )
{
if ( feedback->isCanceled() )
break; //in case some slow data sources are loaded
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/processing/qgsalgorithmconditionalbranch.cpp
Expand Up @@ -87,7 +87,7 @@ QVariantMap QgsConditionalBranchAlgorithm::processAlgorithm( const QVariantMap &
QgsExpressionContext expressionContext = createExpressionContext( parameters, context );

QVariantMap results;
for ( Output *output : qgis::as_const( mOutputs ) )
for ( Output *output : std::as_const( mOutputs ) )
{
output->expression.prepare( &expressionContext );
const QVariant res = output->expression.evaluate( &expressionContext );
Expand Down
8 changes: 4 additions & 4 deletions src/analysis/processing/qgsalgorithmdropfields.cpp
Expand Up @@ -99,7 +99,7 @@ QgsFields QgsDropTableFieldsAlgorithm::outputFields( const QgsFields &inputField
std::sort( mFieldIndices.begin(), mFieldIndices.end(), std::greater< int >() );

// this second time we make a cleaned version of the fields
for ( const int index : qgis::as_const( mFieldIndices ) )
for ( const int index : std::as_const( mFieldIndices ) )
{
outFields.remove( index );
}
Expand All @@ -115,7 +115,7 @@ bool QgsDropTableFieldsAlgorithm::prepareAlgorithm( const QVariantMap &parameter
std::unique_ptr< QgsProcessingFeatureSource> source( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );
if ( source )
{
for ( const QString &field : qgis::as_const( mFieldsToDelete ) )
for ( const QString &field : std::as_const( mFieldsToDelete ) )
{
const int index = source->fields().lookupField( field );
if ( index < 0 )
Expand Down Expand Up @@ -232,7 +232,7 @@ QgsFields QgsRetainTableFieldsAlgorithm::outputFields( const QgsFields &inputFie

// this second time we make a cleaned version of the fields
QgsFields outFields;
for ( const int index : qgis::as_const( mFieldIndices ) )
for ( const int index : std::as_const( mFieldIndices ) )
{
outFields.append( inputFields.at( index ) );
}
Expand All @@ -248,7 +248,7 @@ bool QgsRetainTableFieldsAlgorithm::prepareAlgorithm( const QVariantMap &paramet
std::unique_ptr< QgsProcessingFeatureSource> source( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );
if ( source )
{
for ( const QString &field : qgis::as_const( mFieldsToRetain ) )
for ( const QString &field : std::as_const( mFieldsToRetain ) )
{
const int index = source->fields().lookupField( field );
if ( index < 0 )
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/processing/qgsalgorithmexplodehstore.cpp
Expand Up @@ -140,7 +140,7 @@ QVariantMap QgsExplodeHstoreAlgorithm::processAlgorithm( const QVariantMap &para
QgsFeature outFeature;
step = !features.empty() ? 50.0 / features.count() : 1;
i = 0;
for ( const QgsFeature &feat : qgis::as_const( features ) )
for ( const QgsFeature &feat : std::as_const( features ) )
{
i++;
if ( feedback->isCanceled() )
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/processing/qgsalgorithmextractbylocation.cpp
Expand Up @@ -279,7 +279,7 @@ void QgsLocationBasedAlgorithm::processByIteratingOverIntersectSource( const Qgs

bool isMatch = false;

for ( Predicate predicate : qgis::as_const( predicates ) )
for ( Predicate predicate : std::as_const( predicates ) )
{
switch ( predicate )
{
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/processing/qgsalgorithmextractzmvalues.cpp
Expand Up @@ -127,7 +127,7 @@ QgsFeatureList QgsExtractZMValuesAlgorithmBase::processFeature( const QgsFeature
}
stat.finalize();

for ( QgsStatisticalSummary::Statistic s : qgis::as_const( mSelectedStats ) )
for ( QgsStatisticalSummary::Statistic s : std::as_const( mSelectedStats ) )
attrs.append( stat.statistic( s ) );
}
f.setAttributes( attrs );
Expand Down

0 comments on commit 876ee57

Please sign in to comment.