Use .empty() instead of .size() > 0/.size() >=1/etc

Possibly faster, and clearer to read
This commit is contained in:
Nyall Dawson 2017-09-11 21:21:45 +10:00
parent 2a33844416
commit c17978043c
53 changed files with 98 additions and 96 deletions

View File

@ -37,7 +37,7 @@ QgsInterpolator::QgsInterpolator()
int QgsInterpolator::cacheBaseData()
{
if ( mLayerData.size() < 1 )
if ( mLayerData.empty() )
{
return 0;
}

View File

@ -136,7 +136,7 @@ bool QgsOSMXmlImport::createDatabase()
{
QString version = QString::fromUtf8( results[1] );
QStringList parts = version.split( ' ', QString::SkipEmptyParts );
if ( parts.size() >= 1 )
if ( !parts.empty() )
{
QStringList verparts = parts[0].split( '.', QString::SkipEmptyParts );
above41 = verparts.size() >= 2 && ( verparts[0].toInt() > 4 || ( verparts[0].toInt() == 4 && verparts[1].toInt() >= 1 ) );

View File

@ -340,7 +340,7 @@ void QgsAttributeSelectionDialog::on_mColumnUpPushButton_clicked()
{
//move selected row up
QItemSelection viewSelection( mColumnsTableView->selectionModel()->selection() );
if ( viewSelection.size() > 0 )
if ( !viewSelection.empty() )
{
int selectedRow = viewSelection.indexes().at( 0 ).row();
mColumnModel->moveRow( selectedRow, QgsComposerAttributeTableColumnModelV2::ShiftUp );
@ -351,7 +351,7 @@ void QgsAttributeSelectionDialog::on_mColumnDownPushButton_clicked()
{
//move selected row down
QItemSelection viewSelection( mColumnsTableView->selectionModel()->selection() );
if ( viewSelection.size() > 0 )
if ( !viewSelection.empty() )
{
int selectedRow = viewSelection.indexes().at( 0 ).row();
mColumnModel->moveRow( selectedRow, QgsComposerAttributeTableColumnModelV2::ShiftDown );

View File

@ -2136,7 +2136,7 @@ void QgsComposer::exportCompositionAsImage( QgsComposer::OutputMode mode )
return;
}
QStringList s = dlg.selectedFiles();
if ( s.size() < 1 || s.at( 0 ).isEmpty() )
if ( s.empty() || s.at( 0 ).isEmpty() )
{
return;
}

View File

@ -811,7 +811,7 @@ void QgsDwgImporter::addLType( const DRW_LType &data )
}
QString typeName( data.name.c_str() ), dash( "" );
if ( upath.size() > 0 )
if ( !upath.empty() )
{
QStringList l;
if ( upath[0] < 0 )
@ -1486,7 +1486,7 @@ void QgsDwgImporter::addLWPolyline( const DRW_LWPolyline &data )
.arg( p1.asWkt() ), 5
);
if ( s.size() > 0 && ( width != staWidth || width != endWidth || hadBulge != hasBulge ) )
if ( !s.empty() && ( width != staWidth || width != endWidth || hadBulge != hasBulge ) )
{
if ( hadBulge )
{
@ -1536,7 +1536,7 @@ void QgsDwgImporter::addLWPolyline( const DRW_LWPolyline &data )
if ( staWidth == endWidth )
{
if ( s.size() == 0 )
if ( s.empty() )
{
s << p0;
hadBulge = hasBulge;
@ -1604,7 +1604,7 @@ void QgsDwgImporter::addLWPolyline( const DRW_LWPolyline &data )
}
}
if ( s.size() > 0 )
if ( !s.empty() )
{
if ( hadBulge )
{
@ -1685,7 +1685,7 @@ void QgsDwgImporter::addPolyline( const DRW_Polyline &data )
.arg( p1.asWkt() ), 5
);
if ( s.size() > 0 && ( width != staWidth || width != endWidth || hadBulge != hasBulge ) )
if ( !s.empty() && ( width != staWidth || width != endWidth || hadBulge != hasBulge ) )
{
if ( hadBulge )
{
@ -1737,7 +1737,7 @@ void QgsDwgImporter::addPolyline( const DRW_Polyline &data )
if ( staWidth == endWidth )
{
if ( s.size() == 0 )
if ( s.empty() )
{
s << p0;
hadBulge = hasBulge;
@ -1810,7 +1810,7 @@ void QgsDwgImporter::addPolyline( const DRW_Polyline &data )
}
}
if ( s.size() > 0 )
if ( !s.empty() )
{
if ( hadBulge )
{
@ -2052,7 +2052,7 @@ void QgsDwgImporter::addSpline( const DRW_Spline *data )
}
}
if ( cps.size() > 0 && data->flags & 1 )
if ( !cps.empty() && data->flags & 1 )
{
for ( int i = 0; i < data->degree; ++i )
cps.push_back( cps[i] );

View File

@ -4149,7 +4149,7 @@ void QgisApp::askUserForGDALSublayers( QgsRasterLayer *layer )
QStringList sublayers = layer->subLayers();
QgsDebugMsg( QString( "raster has %1 sublayers" ).arg( layer->subLayers().size() ) );
if ( sublayers.size() < 1 )
if ( sublayers.empty() )
return;
// if promptLayers=Load all, load all sublayers without prompting
@ -4256,7 +4256,7 @@ void QgisApp::askUserForGDALSublayers( QgsRasterLayer *layer )
bool QgisApp::shouldAskUserForGDALSublayers( QgsRasterLayer *layer )
{
// return false if layer is empty or raster has no sublayers
if ( !layer || layer->providerType() != QLatin1String( "gdal" ) || layer->subLayers().size() < 1 )
if ( !layer || layer->providerType() != QLatin1String( "gdal" ) || layer->subLayers().empty() )
return false;
QgsSettings settings;
@ -6151,7 +6151,7 @@ void QgisApp::refreshFeatureActions()
//add actions registered in QgsMapLayerActionRegistry
QList<QgsMapLayerAction *> registeredActions = QgsGui::mapLayerActionRegistry()->mapLayerActions( vlayer );
if ( !actions.isEmpty() && registeredActions.size() > 0 )
if ( !actions.isEmpty() && !registeredActions.empty() )
{
//add a separator between user defined and standard actions
mFeatureActionMenu->addSeparator();

View File

@ -841,7 +841,7 @@ void QgsAttributeTableDialog::on_mActionRemoveAttribute_triggered()
if ( dialog.exec() == QDialog::Accepted )
{
QList<int> attributes = dialog.selectedAttributes();
if ( attributes.size() < 1 )
if ( attributes.empty() )
{
return;
}

View File

@ -44,7 +44,7 @@ QgsMapToolMeasureAngle::~QgsMapToolMeasureAngle()
void QgsMapToolMeasureAngle::canvasMoveEvent( QgsMapMouseEvent *e )
{
if ( !mRubberBand || mAnglePoints.size() < 1 || mAnglePoints.size() > 2 )
if ( !mRubberBand || mAnglePoints.empty() || mAnglePoints.size() > 2 )
{
return;
}
@ -89,7 +89,7 @@ void QgsMapToolMeasureAngle::canvasReleaseEvent( QgsMapMouseEvent *e )
mAnglePoints.clear();
}
if ( mAnglePoints.size() < 1 )
if ( mAnglePoints.empty() )
{
if ( !mResultDisplay )
{

View File

@ -284,7 +284,7 @@ QgsGeometry QgsMapToolOffsetCurve::createOriginGeometry( QgsVectorLayer *vl, con
//for background layers, try to merge selected entries together if snapped feature is contained in selection
const QgsFeatureIds &selection = vl->selectedFeatureIds();
if ( selection.size() < 1 || !selection.contains( match.featureId() ) )
if ( selection.empty() || !selection.contains( match.featureId() ) )
{
return convertToSingleLine( snappedFeature.geometry(), partVertexNr, mMultiPartGeometry );
}

View File

@ -189,7 +189,7 @@ QgsRubberBand *QgsMapToolRotateLabel::createRotationPreviewBox()
{
delete mRotationPreviewBox;
QVector< QgsPointXY > boxPoints = mCurrentLabel.pos.cornerPoints;
if ( boxPoints.size() < 1 )
if ( boxPoints.empty() )
{
return nullptr;
}
@ -210,7 +210,7 @@ void QgsMapToolRotateLabel::setRotationPreviewBox( double rotation )
mRotationPreviewBox->reset();
QVector< QgsPointXY > boxPoints = mCurrentLabel.pos.cornerPoints;
if ( boxPoints.size() < 1 )
if ( boxPoints.empty() )
{
return;
}

View File

@ -154,7 +154,7 @@ void QgsMeasureDialog::mouseMove( const QgsPointXY &point )
double area = mDa.measurePolygon( tmpPoints );
editTotal->setText( formatArea( area ) );
}
else if ( !mMeasureArea && mTool->points().size() >= 1 )
else if ( !mMeasureArea && !mTool->points().empty() )
{
QList< QgsPointXY > tmpPoints = mTool->points();
QgsPointXY p1( tmpPoints.at( tmpPoints.size() - 1 ) ), p2( point );

View File

@ -222,7 +222,7 @@ void QgsMeasureTool::undo()
{
if ( mRubberBand )
{
if ( mPoints.size() < 1 )
if ( mPoints.empty() )
{
return;
}

View File

@ -524,7 +524,7 @@ void QgsMergeAttributesDialog::createRubberBandForFeature( QgsFeatureId featureI
QgsAttributes QgsMergeAttributesDialog::mergedAttributes() const
{
if ( mFeatureList.size() < 1 )
if ( mFeatureList.empty() )
{
return QgsAttributes();
}

View File

@ -1381,7 +1381,7 @@ void QgsProjectProperties::on_mAddWMSComposerButton_clicked()
QString name = QInputDialog::getItem( this, tr( "Select print composer" ), tr( "Composer Title" ), composerTitles, 0, false, &ok );
if ( ok )
{
if ( mComposerListWidget->findItems( name, Qt::MatchExactly ).size() < 1 )
if ( mComposerListWidget->findItems( name, Qt::MatchExactly ).empty() )
{
mComposerListWidget->addItem( name );
}
@ -1407,7 +1407,7 @@ void QgsProjectProperties::on_mAddLayerRestrictionButton_clicked()
QStringList::const_iterator layerIt = layerNames.constBegin();
for ( ; layerIt != layerNames.constEnd(); ++layerIt )
{
if ( mLayerRestrictionsListWidget->findItems( *layerIt, Qt::MatchExactly ).size() < 1 )
if ( mLayerRestrictionsListWidget->findItems( *layerIt, Qt::MatchExactly ).empty() )
{
mLayerRestrictionsListWidget->addItem( *layerIt );
}
@ -1417,7 +1417,7 @@ void QgsProjectProperties::on_mAddLayerRestrictionButton_clicked()
QStringList::const_iterator groupIt = groups.constBegin();
for ( ; groupIt != groups.constEnd(); ++groupIt )
{
if ( mLayerRestrictionsListWidget->findItems( *groupIt, Qt::MatchExactly ).size() < 1 )
if ( mLayerRestrictionsListWidget->findItems( *groupIt, Qt::MatchExactly ).empty() )
{
mLayerRestrictionsListWidget->addItem( *groupIt );
}
@ -1506,7 +1506,7 @@ void QgsProjectProperties::on_pbnLaunchOWSChecker_clicked()
duplicateNames << name;
}
if ( duplicateNames.size() != 0 )
if ( !duplicateNames.empty() )
{
QString nameMessage = "<h1>" + tr( "Some layers and groups have the same name or short name" ) + "</h1>";
nameMessage += "<h2>" + tr( "Duplicate names:" ) + "</h2>";
@ -1518,7 +1518,7 @@ void QgsProjectProperties::on_pbnLaunchOWSChecker_clicked()
teOWSChecker->setHtml( teOWSChecker->toHtml() + "<h1>" + tr( "All names and short names of layer and group are unique" ) + "</h1>" );
}
if ( regExpMessages.size() != 0 )
if ( !regExpMessages.empty() )
{
QString encodingMessage = "<h1>" + tr( "Some layer short names have to be updated:" ) + "</h1><ul><li>" + regExpMessages.join( QStringLiteral( "</li><li>" ) ) + "</li></ul>";
teOWSChecker->setHtml( teOWSChecker->toHtml() + encodingMessage );
@ -1528,7 +1528,7 @@ void QgsProjectProperties::on_pbnLaunchOWSChecker_clicked()
teOWSChecker->setHtml( teOWSChecker->toHtml() + "<h1>" + tr( "All layer short names are well formed" ) + "</h1>" );
}
if ( encodingMessages.size() != 0 )
if ( !encodingMessages.empty() )
{
QString encodingMessage = "<h1>" + tr( "Some layer encodings are not set:" ) + "</h1><ul><li>" + encodingMessages.join( QStringLiteral( "</li><li>" ) ) + "</li></ul>";
teOWSChecker->setHtml( teOWSChecker->toHtml() + encodingMessage );

View File

@ -2235,7 +2235,7 @@ bool QgsAuthManager::rebuildIgnoredSslErrorCache()
bool QgsAuthManager::storeCertAuthorities( const QList<QSslCertificate> &certs )
{
if ( certs.size() < 1 )
if ( certs.isEmpty() )
{
QgsDebugMsg( "Passed certificate list has no certs" );
return false;
@ -2542,7 +2542,7 @@ QgsAuthCertUtils::CertTrustPolicy QgsAuthManager::getCertTrustPolicy( const QSsl
bool QgsAuthManager::removeCertTrustPolicies( const QList<QSslCertificate> &certs )
{
if ( certs.size() < 1 )
if ( certs.empty() )
{
QgsDebugMsg( "Passed certificate list has no certs" );
return false;

View File

@ -1796,7 +1796,7 @@ void QgsComposerMap::transformShift( double &xShift, double &yShift ) const
QPointF QgsComposerMap::mapToItemCoords( QPointF mapCoords ) const
{
QPolygonF mapPoly = transformedMapPolygon();
if ( mapPoly.size() < 1 )
if ( mapPoly.empty() )
{
return QPointF( 0, 0 );
}

View File

@ -1373,7 +1373,7 @@ void QgsComposerMouseHandles::checkNearestItem( double checkCoord, const QMap< d
bool QgsComposerMouseHandles::nearestItem( const QMap< double, const QgsComposerItem * > &coords, double value, double &nearestValue ) const
{
if ( coords.size() < 1 )
if ( coords.empty() )
{
return false;
}

View File

@ -68,7 +68,7 @@ void QgsComposerMultiFrame::setResizeMode( ResizeMode mode )
void QgsComposerMultiFrame::recalculateFrameSizes()
{
if ( mFrameItems.size() < 1 )
if ( mFrameItems.empty() )
{
return;
}
@ -182,7 +182,7 @@ void QgsComposerMultiFrame::recalculateFrameSizes()
void QgsComposerMultiFrame::recalculateFrameRects()
{
if ( mFrameItems.size() < 1 )
if ( mFrameItems.empty() )
{
//no frames, nothing to do
return;

View File

@ -2200,7 +2200,7 @@ QGraphicsLineItem *QgsComposition::nearestSnapLine( const bool horizontal, const
int QgsComposition::boundingRectOfSelectedItems( QRectF &bRect )
{
QList<QgsComposerItem *> selectedItems = selectedComposerItems();
if ( selectedItems.size() < 1 )
if ( selectedItems.empty() )
{
return 1;
}

View File

@ -1071,7 +1071,7 @@ void QgsDxfExport::writeEntities()
else
{
QgsSymbolList symbolList = renderer->symbolsForFeature( fet, ctx );
if ( symbolList.size() < 1 )
if ( symbolList.empty() )
{
continue;
}

View File

@ -160,10 +160,10 @@ void QgsDxfPaintEngine::endPolygon()
void QgsDxfPaintEngine::endCurve()
{
if ( mCurrentCurve.size() < 1 )
if ( mCurrentCurve.empty() )
return;
if ( mCurrentPolygon.size() < 1 )
if ( mCurrentPolygon.empty() )
{
mCurrentCurve.clear();
return;

View File

@ -435,7 +435,7 @@ void QgsCircularString::setPoints( const QgsPointSequence &points )
{
clearCache();
if ( points.size() < 1 )
if ( points.empty() )
{
mWkbType = QgsWkbTypes::Unknown;
mX.clear();

View File

@ -87,7 +87,7 @@ void QgsCompoundCurve::clear()
QgsRectangle QgsCompoundCurve::calculateBoundingBox() const
{
if ( mCurves.size() < 1 )
if ( mCurves.empty() )
{
return QgsRectangle();
}
@ -282,7 +282,7 @@ double QgsCompoundCurve::length() const
QgsPoint QgsCompoundCurve::startPoint() const
{
if ( mCurves.size() < 1 )
if ( mCurves.empty() )
{
return QgsPoint();
}
@ -291,7 +291,7 @@ QgsPoint QgsCompoundCurve::startPoint() const
QgsPoint QgsCompoundCurve::endPoint() const
{
if ( mCurves.size() < 1 )
if ( mCurves.empty() )
{
return QgsPoint();
}
@ -301,7 +301,7 @@ QgsPoint QgsCompoundCurve::endPoint() const
void QgsCompoundCurve::points( QgsPointSequence &pts ) const
{
pts.clear();
if ( mCurves.size() < 1 )
if ( mCurves.empty() )
{
return;
}
@ -489,7 +489,7 @@ void QgsCompoundCurve::drawAsPolygon( QPainter &p ) const
bool QgsCompoundCurve::insertVertex( QgsVertexId position, const QgsPoint &vertex )
{
QList< QPair<int, QgsVertexId> > curveIds = curveVertexId( position );
if ( curveIds.size() < 1 )
if ( curveIds.empty() )
{
return false;
}

View File

@ -573,7 +573,7 @@ void QgsCurvePolygon::removeInteriorRings( double minimumAllowedArea )
void QgsCurvePolygon::draw( QPainter &p ) const
{
if ( mInteriorRings.size() < 1 )
if ( mInteriorRings.empty() )
{
if ( mExteriorRing )
{

View File

@ -2145,7 +2145,7 @@ QPolygonF QgsGeometry::asQPolygonF() const
else if ( type == QgsWkbTypes::Polygon || type == QgsWkbTypes::Polygon25D )
{
QgsPolygon polygon = asPolygon();
if ( polygon.size() < 1 )
if ( polygon.empty() )
return result;
polyline = polygon.at( 0 );
}
@ -2575,7 +2575,7 @@ void QgsGeometry::convertPolygon( const QgsPolygonV2 &input, QgsPolygon &output
{
output.clear();
QgsCoordinateSequence coords = input.coordinateSequence();
if ( coords.size() < 1 )
if ( coords.empty() )
{
return;
}

View File

@ -344,7 +344,7 @@ QgsRectangle QgsGeometryCollection::boundingBox() const
QgsRectangle QgsGeometryCollection::calculateBoundingBox() const
{
if ( mGeometries.size() < 1 )
if ( mGeometries.empty() )
{
return QgsRectangle();
}

View File

@ -2522,7 +2522,7 @@ GEOSGeometry *QgsGeos::reshapeLine( const GEOSGeometry *line, const GEOSGeometry
GEOSGeom_destroy_r( geosinit.ctxt, mergedLines );
GEOSGeometry *result = nullptr;
if ( resultLineParts.size() < 1 )
if ( resultLineParts.empty() )
return nullptr;
if ( resultLineParts.size() == 1 ) //the whole result was reshaped

View File

@ -76,7 +76,7 @@ QPolygonF QgsClipper::clippedLine( const QgsCurve &curve, const QgsRectangle &cl
//add edge points to connect old and new line
connectSeparatedLines( lastClipX, lastClipY, p0x, p0y, clipExtent, line );
}
if ( line.size() < 1 || newLine )
if ( line.empty() || newLine )
{
//add first point
line << QPointF( p0x, p0y );

View File

@ -334,7 +334,8 @@ QgsColorRamp *QgsLimitedRandomColorRamp::create( const QgsStringMap &props )
double QgsLimitedRandomColorRamp::value( int index ) const
{
if ( mColors.size() < 1 ) return 0;
if ( mColors.empty() )
return 0;
return static_cast< double >( index ) / ( mColors.size() - 1 );
}
@ -548,7 +549,8 @@ QList<int> QgsColorBrewerColorRamp::listSchemeVariants( const QString &schemeNam
double QgsColorBrewerColorRamp::value( int index ) const
{
if ( mPalette.size() < 1 ) return 0;
if ( mPalette.empty() )
return 0;
return static_cast< double >( index ) / ( mPalette.size() - 1 );
}
@ -865,7 +867,7 @@ QList<QColor> QgsPresetSchemeColorRamp::colors() const
double QgsPresetSchemeColorRamp::value( int index ) const
{
if ( mColors.size() < 1 )
if ( mColors.empty() )
return 0;
return static_cast< double >( index ) / ( mColors.size() - 1 );
}

View File

@ -413,7 +413,7 @@ void QgsEditFormConfig::writeXml( QDomNode &node, const QgsReadWriteContext &con
node.appendChild( editorLayoutElem );
// tabs and groups of edit form
if ( tabs().size() > 0 && d->mConfiguredRootContainer )
if ( !tabs().empty() && d->mConfiguredRootContainer )
{
QDomElement tabsElem = doc.createElement( QStringLiteral( "attributeEditorForm" ) );

View File

@ -223,7 +223,7 @@ void QgsGml::handleProgressEvent( qint64 progress, qint64 totalSteps )
void QgsGml::calculateExtentFromFeatures()
{
if ( mFeatures.size() < 1 )
if ( mFeatures.empty() )
{
return;
}

View File

@ -159,7 +159,7 @@ QList<QgsLegendRenderer::Atom> QgsLegendRenderer::createAtomList( QgsLayerTreeGr
// Group subitems
QList<Atom> groupAtoms = createAtomList( nodeGroup, splitLayer );
bool hasSubItems = groupAtoms.size() > 0;
bool hasSubItems = !groupAtoms.empty();
if ( nodeLegendStyle( nodeGroup ) != QgsLegendStyle::Hidden )
{

View File

@ -367,10 +367,10 @@ void QgsOfflineEditing::initializeSpatialMetadata( sqlite3 *sqlite_handle )
{
QString version = QString::fromUtf8( results[1] );
QStringList parts = version.split( ' ', QString::SkipEmptyParts );
if ( parts.size() >= 1 )
if ( !parts.empty() )
{
QStringList verparts = parts[0].split( '.', QString::SkipEmptyParts );
above41 = verparts.size() >= 2 && ( verparts[0].toInt() > 4 || ( verparts[0].toInt() == 4 && verparts[1].toInt() >= 1 ) );
QStringList verparts = parts.at( 0 ).split( '.', QString::SkipEmptyParts );
above41 = verparts.size() >= 2 && ( verparts.at( 0 ).toInt() > 4 || ( verparts.at( 0 ).toInt() == 4 && verparts.at( 1 ).toInt() >= 1 ) );
}
}

View File

@ -170,7 +170,7 @@ QgsGeometry QgsOgcUtils::geometryFromGMLPoint( const QDomElement &geometryElemen
}
}
if ( pointCoordinate.size() < 1 )
if ( pointCoordinate.empty() )
{
return QgsGeometry();
}
@ -416,7 +416,7 @@ QgsGeometry QgsOgcUtils::geometryFromGMLMultiPoint( const QDomElement &geometryE
{
continue;
}
if ( currentPoint.size() < 1 )
if ( currentPoint.empty() )
{
continue;
}
@ -436,7 +436,7 @@ QgsGeometry QgsOgcUtils::geometryFromGMLMultiPoint( const QDomElement &geometryE
{
continue;
}
if ( currentPoint.size() < 1 )
if ( currentPoint.empty() )
{
continue;
}
@ -2950,7 +2950,7 @@ QString QgsOgcUtilsSQLStatementToFilter::getGeometryColumnSRSName( const QgsSQLS
}
}
}
if ( mLayerProperties.size() != 0 &&
if ( !mLayerProperties.empty() &&
mLayerProperties.at( 0 ).mGeometryAttribute.compare( col->name(), Qt::CaseInsensitive ) == 0 )
{
return mLayerProperties.at( 0 ).mSRSName;
@ -3337,7 +3337,7 @@ QDomElement QgsOgcUtilsSQLStatementToFilter::toOgcFilter( const QgsSQLStatement:
QList<QDomElement> listElem;
if ( mFilterVersion != QgsOgcUtils::FILTER_FES_2_0 &&
( node->tables().size() != 1 || node->joins().size() != 0 ) )
( node->tables().size() != 1 || !node->joins().empty() ) )
{
mErrorMessage = QObject::tr( "Joins are only supported with WFS 2.0" );
return QDomElement();

View File

@ -2628,7 +2628,7 @@ QgsVectorFileWriter::writeAsVectorFormat( QgsVectorLayer *layer,
if ( fet.hasGeometry() && filterRectEngine && !filterRectEngine->intersects( fet.geometry().geometry() ) )
continue;
if ( attributes.size() < 1 && options.skipAttributeCreation )
if ( attributes.empty() && options.skipAttributeCreation )
{
fet.initAttributes( 0 );
}

View File

@ -1154,7 +1154,7 @@ int QgsVectorLayer::addPart( const QList<QgsPointXY> &points )
//number of selected features must be 1
if ( mSelectedFeatureIds.size() < 1 )
if ( mSelectedFeatureIds.empty() )
{
QgsDebugMsg( "Number of selected features <1" );
return 4;
@ -1180,7 +1180,7 @@ int QgsVectorLayer::addPart( const QgsPointSequence &points )
//number of selected features must be 1
if ( mSelectedFeatureIds.size() < 1 )
if ( mSelectedFeatureIds.empty() )
{
QgsDebugMsg( "Number of selected features <1" );
return 4;
@ -1206,7 +1206,7 @@ int QgsVectorLayer::addPart( QgsCurve *ring )
//number of selected features must be 1
if ( mSelectedFeatureIds.size() < 1 )
if ( mSelectedFeatureIds.empty() )
{
QgsDebugMsg( "Number of selected features <1" );
return 4;

View File

@ -678,7 +678,7 @@ int QgsVectorLayerEditUtils::addTopologicalPoints( const QgsPointXY &p )
bool QgsVectorLayerEditUtils::boundingBoxFromPointList( const QList<QgsPointXY> &list, double &xmin, double &ymin, double &xmax, double &ymax ) const
{
if ( list.size() < 1 )
if ( list.empty() )
{
return false;
}

View File

@ -671,7 +671,7 @@ void QgsVectorLayerFeatureIterator::prepareFields()
}
//sort joins by dependency
if ( mFetchJoinInfo.size() > 0 )
if ( !mFetchJoinInfo.empty() )
{
createOrderedJoinList();
}

View File

@ -157,7 +157,7 @@ QgsRasterBlock *QgsMultiBandColorRenderer::block( int bandNo, QgsRectangle cons
{
bands << mBlueBand;
}
if ( bands.size() < 1 )
if ( bands.empty() )
{
// no need to draw anything if no band is set
// TODO:: we should probably return default color block

View File

@ -802,7 +802,7 @@ void QgsArrowSymbolLayer::renderPolyline( const QPolygonF &points, QgsSymbolRend
void QgsArrowSymbolLayer::setColor( const QColor &c )
{
if ( mSymbol.get() )
if ( mSymbol )
mSymbol->setColor( c );
mColor = c;

View File

@ -957,7 +957,7 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
if ( drawVertexMarker )
{
if ( markers.size() > 0 )
if ( !markers.isEmpty() )
{
Q_FOREACH ( QPointF marker, markers )
{

View File

@ -212,7 +212,7 @@ void QgsAuthAuthoritiesEditor::appendCertsToGroup( const QList<QSslCertificate>
QgsAuthAuthoritiesEditor::CaType catype,
QTreeWidgetItem *parent )
{
if ( certs.size() < 1 )
if ( certs.empty() )
return;
if ( !parent )
@ -251,7 +251,7 @@ void QgsAuthAuthoritiesEditor::appendCertsToItem( const QList<QSslCertificate> &
QgsAuthAuthoritiesEditor::CaType catype,
QTreeWidgetItem *parent )
{
if ( certs.size() < 1 )
if ( certs.empty() )
return;
if ( !parent )

View File

@ -154,7 +154,7 @@ bool QgsAuthCertInfo::populateQcaCertCollection()
}
}
if ( mCaCerts.certificates().size() < 1 )
if ( mCaCerts.certificates().empty() )
{
setupError( tr( "Could not populate QCA certificate collection" ) );
return false;

View File

@ -141,7 +141,7 @@ void QgsAuthIdentitiesEditor::appendIdentitiesToGroup( const QList<QSslCertifica
QgsAuthIdentitiesEditor::IdentityType identype,
QTreeWidgetItem *parent )
{
if ( certs.size() < 1 )
if ( certs.empty() )
return;
if ( !parent )
@ -180,7 +180,7 @@ void QgsAuthIdentitiesEditor::appendIdentitiesToItem( const QList<QSslCertificat
QgsAuthIdentitiesEditor::IdentityType identype,
QTreeWidgetItem *parent )
{
if ( certs.size() < 1 )
if ( certs.empty() )
return;
if ( !parent )

View File

@ -141,7 +141,7 @@ void QgsAuthServersEditor::appendSslConfigsToGroup( const QList<QgsAuthConfigSsl
QgsAuthServersEditor::ConfigType conftype,
QTreeWidgetItem *parent )
{
if ( configs.size() < 1 )
if ( configs.empty() )
return;
if ( !parent )
@ -180,7 +180,7 @@ void QgsAuthServersEditor::appendSslConfigsToItem( const QList<QgsAuthConfigSslS
QgsAuthServersEditor::ConfigType conftype,
QTreeWidgetItem *parent )
{
if ( configs.size() < 1 )
if ( configs.empty() )
return;
if ( !parent )

View File

@ -134,7 +134,7 @@ void QgsAuthTrustedCAsDialog::appendCertsToGroup( const QList<QSslCertificate> &
QgsAuthTrustedCAsDialog::CaType catype,
QTreeWidgetItem *parent )
{
if ( certs.size() < 1 )
if ( certs.empty() )
return;
if ( !parent )
@ -173,7 +173,7 @@ void QgsAuthTrustedCAsDialog::appendCertsToItem( const QList<QSslCertificate> &c
QgsAuthTrustedCAsDialog::CaType catype,
QTreeWidgetItem *parent )
{
if ( certs.size() < 1 )
if ( certs.empty() )
return;
if ( !parent )

View File

@ -471,7 +471,7 @@ void QgsVectorLayerSaveAsDialog::on_mFormatComboBox_currentIndexChanged( int idx
if ( QgsVectorFileWriter::driverMetadata( format(), driverMetaData ) )
{
if ( driverMetaData.driverOptions.size() != 0 )
if ( !driverMetaData.driverOptions.empty() )
{
mDatasourceOptionsGroupBox->setVisible( true );
QList<QPair<QLabel *, QWidget *> > controls = createControls( driverMetaData.driverOptions );
@ -488,7 +488,7 @@ void QgsVectorLayerSaveAsDialog::on_mFormatComboBox_currentIndexChanged( int idx
mDatasourceOptionsGroupBox->setVisible( false );
}
if ( driverMetaData.layerOptions.size() != 0 )
if ( !driverMetaData.layerOptions.empty() )
{
mLayerOptionsGroupBox->setVisible( true );
QList<QPair<QLabel *, QWidget *> > controls = createControls( driverMetaData.layerOptions );

View File

@ -701,7 +701,7 @@ void QgsOWSSourceSelect::on_mSearchTableWidget_itemSelectionChanged()
void QgsOWSSourceSelect::on_mLayerUpButton_clicked()
{
QList<QTreeWidgetItem *> selectionList = mLayerOrderTreeWidget->selectedItems();
if ( selectionList.size() < 1 )
if ( selectionList.empty() )
{
return;
}
@ -720,7 +720,7 @@ void QgsOWSSourceSelect::on_mLayerUpButton_clicked()
void QgsOWSSourceSelect::on_mLayerDownButton_clicked()
{
QList<QTreeWidgetItem *> selectionList = mLayerOrderTreeWidget->selectedItems();
if ( selectionList.size() < 1 )
if ( selectionList.empty() )
{
return;
}

View File

@ -198,7 +198,7 @@ void QgsRubberBand::movePoint( const QgsPointXY &p, int geometryIndex )
return;
}
if ( mPoints.at( geometryIndex ).size() < 1 )
if ( mPoints.at( geometryIndex ).empty() )
{
return;
}

View File

@ -215,7 +215,7 @@ QList<QgsOgrDbLayerInfo *> QgsOgrLayerItem::subLayers( const QString &path, cons
}
// Raster layers
QgsRasterLayer rlayer( path, QStringLiteral( "gdal_tmp" ), QStringLiteral( "gdal" ), false );
if ( rlayer.dataProvider()->subLayers( ).size() > 0 )
if ( !rlayer.dataProvider()->subLayers( ).empty() )
{
const QStringList layers( rlayer.dataProvider()->subLayers( ) );
for ( const QString &uri : layers )

View File

@ -190,7 +190,7 @@ void QgsPgTableModel::setSql( const QModelIndex &index, const QString &sql )
QString geomName = itemFromIndex( geomSibling )->text();
QList<QStandardItem *> schemaItems = findItems( schemaName, Qt::MatchExactly, DbtmSchema );
if ( schemaItems.size() < 1 )
if ( schemaItems.empty() )
{
return;
}

View File

@ -5330,10 +5330,10 @@ static bool initializeSpatialMetadata( sqlite3 *sqlite_handle, QString &errCause
{
QString version = QString::fromUtf8( results[1] );
QStringList parts = version.split( ' ', QString::SkipEmptyParts );
if ( parts.size() >= 1 )
if ( !parts.empty() )
{
QStringList verparts = parts[0].split( '.', QString::SkipEmptyParts );
above41 = verparts.size() >= 2 && ( verparts[0].toInt() > 4 || ( verparts[0].toInt() == 4 && verparts[1].toInt() >= 1 ) );
QStringList verparts = parts.at( 0 ).split( '.', QString::SkipEmptyParts );
above41 = verparts.size() >= 2 && ( verparts.at( 0 ).toInt() > 4 || ( verparts.at( 0 ).toInt() == 4 && verparts.at( 1 ).toInt() >= 1 ) );
}
}

View File

@ -103,7 +103,7 @@ void QgsSpatiaLiteTableModel::setGeometryTypesForTable( const QString &table, co
QStandardItem *dbItem = nullptr;
QList < QStandardItem * >dbItems = findItems( mSqliteDb, Qt::MatchExactly, 0 );
if ( dbItems.size() < 1 )
if ( dbItems.empty() )
{
return;
}