Skip to content
Permalink
Browse files
Avoid unnecessary temporary container and double iteration over
containers by directly iterating over container itself, rather
then iterating over .keys()/.values()
  • Loading branch information
nyalldawson committed May 15, 2016
1 parent 77c4ed5 commit e25ffc4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
@@ -66,9 +66,10 @@ class CORE_EXPORT QgsMapLayerRegistry : public QObject
QVector<T> layers() const
{
QVector<T> layers;
Q_FOREACH ( QgsMapLayer* layer, mMapLayers.values() )
QMap<QString, QgsMapLayer*>::const_iterator layerIt = mMapLayers.constBegin();
for ( ; layerIt != mMapLayers.constEnd(); ++layerIt )
{
T tLayer = qobject_cast<T>( layer );
T tLayer = qobject_cast<T>( layerIt.value() );
if ( tLayer )
{
layers << tLayer;
@@ -154,7 +154,13 @@ QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator( QgsVectorLayerFeat
if ( mSource->mHasEditBuffer )
{
mChangedFeaturesRequest = mProviderRequest;
mChangedFeaturesRequest.setFilterFids( mSource->mChangedAttributeValues.keys().toSet() );
QgsFeatureIds changedIds;
QgsChangedAttributesMap::const_iterator attIt = mSource->mChangedAttributeValues.constBegin();
for ( ; attIt != mSource->mChangedAttributeValues.constEnd(); ++attIt )
{
changedIds << attIt.key();
}
mChangedFeaturesRequest.setFilterFids( changedIds );
}

if ( request.filterType() == QgsFeatureRequest::FilterFid )
@@ -657,11 +657,12 @@ QStringList QgsOgrProvider::subLayers() const
fCount[wkbUnknown] = 0;
}
bool bIs25D = (( layerGeomType & wkb25DBit ) != 0 );
Q_FOREACH ( OGRwkbGeometryType gType, fCount.keys() )
QMap<OGRwkbGeometryType, int>::const_iterator countIt = fCount.constBegin();
for ( ; countIt != fCount.constEnd(); ++countIt )
{
QString geom = ogrWkbGeometryTypeName(( bIs25D ) ? ( OGRwkbGeometryType )( gType | wkb25DBit ) : gType );
QString geom = ogrWkbGeometryTypeName(( bIs25D ) ? ( OGRwkbGeometryType )( countIt.key() | wkb25DBit ) : countIt.key() );

QString sl = QString( "%1:%2:%3:%4" ).arg( i ).arg( theLayerName ).arg( fCount.value( gType ) ).arg( geom );
QString sl = QString( "%1:%2:%3:%4" ).arg( i ).arg( theLayerName ).arg( fCount.value( countIt.key() ) ).arg( geom );
QgsDebugMsg( "sub layer: " + sl );
mSubLayerList << sl;
}

0 comments on commit e25ffc4

Please sign in to comment.