Skip to content
Permalink
Browse files

Fix some more const auto& = usage where temporaries are stored

as references, and avoid using auto where its not wanted
  • Loading branch information
nyalldawson committed Jan 29, 2020
1 parent b3f37fd commit 4fe056bf66a2d4b0e485aefa457729b8ee32ef10
@@ -90,7 +90,7 @@ QgsGeometry QgsMeshContours::exportPolygons(
if ( !mScalarActiveFaceFlagValues.active( nativeIndex ) )
continue;

const auto &triangle = mTriangularMesh->triangles().at( i );
const QgsMeshFace &triangle = mTriangularMesh->triangles().at( i );
const int indices[3] =
{
triangle.at( 0 ),
@@ -279,7 +279,7 @@ QgsGeometry QgsMeshContours::exportLines( const QgsMeshDatasetIndex &index,
if ( !mScalarActiveFaceFlagValues.active( nativeIndex ) )
continue;

const auto &triangle = mTriangularMesh->triangles().at( i );
const QgsMeshFace &triangle = mTriangularMesh->triangles().at( i );

const int indices[3] =
{
@@ -497,8 +497,7 @@ void QgsMeshCalculatorDialog::populateDriversComboBox( )

whileBlocking( mOutputFormatComboBox )->clear();

const auto &vals = mMeshDrivers.values();

const QList< QgsMeshDriverMetadata > vals = mMeshDrivers.values();
for ( const QgsMeshDriverMetadata &meta : vals )
{
whileBlocking( mOutputFormatComboBox )->addItem( meta.description(), meta.name() );
@@ -61,12 +61,12 @@ int QgsGeometryValidationModel::columnCount( const QModelIndex &parent ) const

QVariant QgsGeometryValidationModel::data( const QModelIndex &index, int role ) const
{
const auto &layerErrors = mErrorStorage.value( mCurrentLayer );
const QList< FeatureErrors > layerErrors = mErrorStorage.value( mCurrentLayer );

if ( index.row() >= layerErrors.size() )
{
// Topology error
const auto &topologyErrors = mTopologyErrorStorage.value( mCurrentLayer );
const QList< std::shared_ptr< QgsGeometryCheckError > > topologyErrors = mTopologyErrorStorage.value( mCurrentLayer );
auto topologyError = topologyErrors.at( index.row() - layerErrors.size() );

switch ( role )
@@ -149,7 +149,7 @@ QVariant QgsGeometryValidationModel::data( const QModelIndex &index, int role )
else
{
// Geometry error
const auto &featureItem = layerErrors.at( index.row() );
const FeatureErrors &featureItem = layerErrors.at( index.row() );

switch ( role )
{
@@ -381,8 +381,8 @@ void QgsGeometryValidationModel::onTopologyErrorUpdated( QgsVectorLayer *layer,
if ( layer == mCurrentLayer )
{
int i = 0;
const auto &errors = mTopologyErrorStorage[layer];
for ( const auto &currentError : errors )
const QList< std::shared_ptr< QgsGeometryCheckError > > errors = mTopologyErrorStorage[layer];
for ( const std::shared_ptr< QgsGeometryCheckError > &currentError : errors )
{
if ( currentError.get() == error )
{
@@ -396,10 +396,10 @@ void QgsGeometryValidationModel::onTopologyErrorUpdated( QgsVectorLayer *layer,

int QgsGeometryValidationModel::errorsForFeature( QgsVectorLayer *layer, QgsFeatureId fid )
{
const auto &layerErrors = mErrorStorage[layer];
const QList< FeatureErrors > layerErrors = mErrorStorage[layer];
int idx = 0;

for ( const auto &feature : layerErrors )
for ( const FeatureErrors &feature : layerErrors )
{
if ( feature.fid == fid )
return idx;
@@ -207,7 +207,7 @@ QVector<double> QgsMeshLayerUtils::interpolateFromFacesData(
if ( !std::isnan( val ) )
{
// assign for all vertices
const auto &face = nativeMesh->faces.at( i );
const QgsMeshFace &face = nativeMesh->faces.at( i );
for ( int j = 0; j < face.size(); ++j )
{
int vertexIndex = face[j];
@@ -67,8 +67,8 @@ void QgsCodeEditorExpression::setExpressionContext( const QgsExpressionContext &
signature += '(';

QStringList paramNames;
const auto &parameters = func->parameters();
for ( const auto &param : parameters )
const QgsExpressionFunction::ParameterList parameters = func->parameters();
for ( const QgsExpressionFunction::Parameter &param : parameters )
{
paramNames << param.name();
}
@@ -329,7 +329,7 @@ QgsFeatureRequest QgsBackgroundCachedFeatureIterator::buildRequestCache( int gen
{
QgsFeatureRequest requestCache;

const auto &fields = mShared->fields();
const QgsFields fields = mShared->fields();

auto cacheDataProvider = mShared->cacheDataProvider();
if ( mRequest.filterType() == QgsFeatureRequest::FilterFid ||
@@ -126,15 +126,15 @@ void QgsOapifItemsRequest::processReply()
const json j = json::parse( utf8Text.toStdString() );
if ( j.is_object() && j.contains( "features" ) )
{
const auto features = j["features"];
const json features = j["features"];
if ( features.is_array() && features.size() == mFeatures.size() )
{
for ( size_t i = 0; i < features.size(); i++ )
{
const auto &jFeature = features[i];
const json &jFeature = features[i];
if ( jFeature.is_object() && jFeature.contains( "id" ) )
{
const auto id = jFeature["id"];
const json id = jFeature["id"];
if ( id.is_string() )
{
mFeatures[i].second = QString::fromStdString( id.get<std::string>() );
@@ -647,7 +647,7 @@ void QgsOapifFeatureDownloaderImpl::run( bool serializeFeatures, int maxFeatures
hasQueryParam = true;
}

const auto &rect = mShared->currentRect();
const QgsRectangle &rect = mShared->currentRect();
if ( !rect.isNull() )
{
// Clamp to avoid server errors.
@@ -717,8 +717,8 @@ void QgsOapifFeatureDownloaderImpl::run( bool serializeFeatures, int maxFeatures

QVector<QgsFeatureUniqueIdPair> featureList;
size_t i = 0;
const auto &srcFields = itemsRequest.fields();
const auto &dstFields = mShared->fields();
const QgsFields srcFields = itemsRequest.fields();
const QgsFields dstFields = mShared->fields();
for ( const auto &pair : itemsRequest.features() )
{
// In the case the features of the current page have not the same schema
@@ -157,7 +157,7 @@ QUrl QgsWFSFeatureDownloaderImpl::buildURL( qint64 startIndex, int maxFeatures,
getFeatureUrl.addQueryItem( QStringLiteral( "SRSNAME" ), srsName );
}

const auto &rect = mShared->currentRect();
const QgsRectangle &rect = mShared->currentRect();

// In case we must issue a BBOX and we have a filter, we must combine
// both as a single filter, as both BBOX and FILTER aren't supported together
@@ -83,7 +83,7 @@ void QgsWFSNewConnection::capabilitiesReplyFinished()
return;
}

const auto &caps = mCapabilities->capabilities();
const QgsWfsCapabilities::Capabilities &caps = mCapabilities->capabilities();
int versionIdx = WFS_VERSION_MAX;
wfsPageSizeLineEdit()->clear();
if ( caps.version.startsWith( QLatin1String( "1.0" ) ) )

0 comments on commit 4fe056b

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