Skip to content
Permalink
Browse files

More efficient case insensitive string comparison

  • Loading branch information
nyalldawson committed Sep 4, 2018
1 parent 3014bbf commit 0b4694fbee5aeb728c7071a85cee4ba686008f77
Showing with 133 additions and 133 deletions.
  1. +2 −2 src/app/dwg/qgsdwgimporter.cpp
  2. +1 −1 src/app/layout/qgslayoutmanagerdialog.cpp
  3. +5 −5 src/app/qgisapp.cpp
  4. +1 −1 src/app/qgsaddattrdialog.cpp
  5. +5 −5 src/app/qgsappbrowserproviders.cpp
  6. +1 −1 src/app/qgsdecorationnortharrow.cpp
  7. +10 −10 src/auth/basic/qgsauthbasicmethod.cpp
  8. +5 −5 src/core/layout/qgscompositionconverter.cpp
  9. +1 −1 src/core/layout/qgslayoutitem.cpp
  10. +2 −2 src/core/layout/qgslayoutitempage.cpp
  11. +20 −20 src/core/processing/qgsprocessingparameters.cpp
  12. +1 −1 src/core/processing/qgsprocessingregistry.cpp
  13. +3 −3 src/core/processing/qgsprocessingutils.cpp
  14. +1 −1 src/core/providers/memory/qgsmemoryprovider.cpp
  15. +1 −1 src/core/qgsapplication.cpp
  16. +3 −3 src/core/qgsauxiliarystorage.cpp
  17. +1 −1 src/core/qgscoordinatereferencesystem.cpp
  18. +2 −2 src/core/qgsdataitem.cpp
  19. +1 −1 src/core/qgseditformconfig.cpp
  20. +1 −1 src/core/qgsnetworkaccessmanager.cpp
  21. +2 −2 src/core/qgsogcutils.cpp
  22. +3 −3 src/core/qgsowsconnection.cpp
  23. +1 −1 src/core/raster/qgsrasterfilewriter.cpp
  24. +1 −1 src/core/symbology/qgssymbol.cpp
  25. +1 −1 src/core/symbology/qgssymbollayerutils.cpp
  26. +1 −1 src/gui/qgscollapsiblegroupbox.cpp
  27. +1 −1 src/gui/qgshelp.cpp
  28. +3 −3 src/gui/qgsowssourceselect.cpp
  29. +1 −1 src/gui/qgssvgsourcelineedit.cpp
  30. +1 −1 src/gui/qgstextformatwidget.cpp
  31. +1 −1 src/providers/gdal/qgsgdalprovider.cpp
  32. +1 −1 src/providers/geonode/qgsgeonodedataitems.cpp
  33. +4 −4 src/providers/mssql/qgsmssqlprovider.cpp
  34. +2 −2 src/providers/spatialite/qgsspatialiteprovider.cpp
  35. +2 −2 src/providers/virtual/qgsvirtuallayerprovider.cpp
  36. +3 −3 src/providers/wcs/qgswcsprovider.cpp
  37. +1 −1 src/providers/wfs/qgswfsprovider.cpp
  38. +2 −2 src/providers/wms/qgswmsprovider.cpp
  39. +4 −4 src/server/qgsserverparameters.cpp
  40. +1 −1 src/server/services/wcs/qgswcs.cpp
  41. +1 −1 src/server/services/wfs/qgswfs.cpp
  42. +4 −4 src/server/services/wfs/qgswfsgetfeature.cpp
  43. +4 −4 src/server/services/wms/qgswms.cpp
  44. +7 −7 src/server/services/wms/qgswmsgetprint.cpp
  45. +1 −1 src/server/services/wms/qgswmsparameters.cpp
  46. +1 −1 src/server/services/wms/qgswmsrenderer.cpp
  47. +1 −1 src/server/services/wmts/qgswmts.cpp
  48. +9 −9 tests/src/analysis/testqgsprocessing.cpp
  49. +2 −2 tests/src/core/testqgsgeonodeconnection.cpp
@@ -593,7 +593,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa

DRW::error result( DRW::BAD_NONE );

if ( fi.suffix().toLower() == QLatin1String( "dxf" ) )
if ( fi.suffix().compare( QLatin1String( "dxf" ), Qt::CaseInsensitive ) == 0 )
{
//loads dxf
std::unique_ptr<dxfRW> dxf( new dxfRW( drawing.toLocal8Bit() ) );
@@ -602,7 +602,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
result = DRW::BAD_UNKNOWN;
}
}
else if ( fi.suffix().toLower() == QLatin1String( "dwg" ) )
else if ( fi.suffix().compare( QLatin1String( "dwg" ), Qt::CaseInsensitive ) == 0 )
{
//loads dwg
std::unique_ptr<dwgR> dwg( new dwgR( drawing.toLocal8Bit() ) );
@@ -190,7 +190,7 @@ QMap<QString, QString> QgsLayoutManagerDialog::templatesFromPath( const QString
QFileInfoList::const_iterator infoIt = fileInfoList.constBegin();
for ( ; infoIt != fileInfoList.constEnd(); ++infoIt )
{
if ( infoIt->suffix().toLower() == QLatin1String( "qpt" ) )
if ( infoIt->suffix().compare( QLatin1String( "qpt" ), Qt::CaseInsensitive ) == 0 )
{
templateMap.insert( infoIt->baseName(), infoIt->absoluteFilePath() );
}
@@ -6201,20 +6201,20 @@ void QgisApp::openFile( const QString &fileName, const QString &fileTypeHint )
{
// check to see if we are opening a project file
QFileInfo fi( fileName );
if ( fileTypeHint == QStringLiteral( "project" ) || fi.suffix().toLower() == QLatin1String( "qgs" ) || fi.suffix().toLower() == QLatin1String( "qgz" ) )
if ( fileTypeHint == QStringLiteral( "project" ) || fi.suffix().compare( QLatin1String( "qgs" ), Qt::CaseInsensitive ) == 0 || fi.suffix().compare( QLatin1String( "qgz" ), Qt::CaseInsensitive ) == 0 )
{
QgsDebugMsg( "Opening project " + fileName );
openProject( fileName );
}
else if ( fi.suffix().toLower() == QLatin1String( "qlr" ) )
else if ( fi.suffix().compare( QLatin1String( "qlr" ), Qt::CaseInsensitive ) == 0 )
{
openLayerDefinition( fileName );
}
else if ( fi.suffix().toLower() == QLatin1String( "qpt" ) )
else if ( fi.suffix().compare( QLatin1String( "qpt" ), Qt::CaseInsensitive ) == 0 )
{
openTemplate( fileName );
}
else if ( fi.suffix().toLower() == QLatin1String( "py" ) )
else if ( fi.suffix().compare( QLatin1String( "py" ), Qt::CaseInsensitive ) == 0 )
{
runScript( fileName );
}
@@ -12790,7 +12790,7 @@ bool QgisApp::addRasterLayers( QStringList const &fileNameQStringList, bool guiW
//time to prevent the user selecting all adfs in 1 dir which
//actually represent 1 coverate,

if ( myFileInfo.fileName().toLower().endsWith( QLatin1String( ".adf" ) ) )
if ( myFileInfo.fileName().endsWith( QLatin1String( ".adf" ), Qt::CaseInsensitive ) )
{
break;
}
@@ -93,7 +93,7 @@ void QgsAddAttrDialog::setPrecisionMinMax()

void QgsAddAttrDialog::accept()
{
if ( mIsShapeFile && mNameEdit->text().toLower() == QLatin1String( "shape" ) )
if ( mIsShapeFile && mNameEdit->text().compare( QLatin1String( "shape" ), Qt::CaseInsensitive ) == 0 )
{
QMessageBox::warning( this, tr( "Add Field" ),
tr( "Invalid field name. This field name is reserved and cannot be used." ) );
@@ -62,7 +62,7 @@ QgsDataItem *QgsQlrDataItemProvider::createDataItem( const QString &path, QgsDat
{
QFileInfo fileInfo( path );

if ( fileInfo.suffix().compare( QStringLiteral( "qlr" ), Qt::CaseInsensitive ) == 0 )
if ( fileInfo.suffix().compare( QLatin1String( "qlr" ), Qt::CaseInsensitive ) == 0 )
{
return new QgsQlrDataItem( parentItem, fileInfo.fileName(), path );
}
@@ -98,7 +98,7 @@ QgsDataItem *QgsQptDataItemProvider::createDataItem( const QString &path, QgsDat
{
QFileInfo fileInfo( path );

if ( fileInfo.suffix().compare( QStringLiteral( "qpt" ), Qt::CaseInsensitive ) == 0 )
if ( fileInfo.suffix().compare( QLatin1String( "qpt" ), Qt::CaseInsensitive ) == 0 )
{
return new QgsQptDataItem( parentItem, fileInfo.baseName(), path );
}
@@ -123,7 +123,7 @@ void QgsQptDropHandler::handleCustomUriDrop( const QgsMimeDataUtils::Uri &uri )
bool QgsQptDropHandler::handleFileDrop( const QString &file )
{
QFileInfo fi( file );
if ( fi.completeSuffix().compare( QStringLiteral( "qpt" ), Qt::CaseInsensitive ) == 0 )
if ( fi.completeSuffix().compare( QLatin1String( "qpt" ), Qt::CaseInsensitive ) == 0 )
{
QgisApp::instance()->openTemplate( file );
return true;
@@ -240,7 +240,7 @@ QgsDataItem *QgsPyDataItemProvider::createDataItem( const QString &path, QgsData
{
QFileInfo fileInfo( path );

if ( fileInfo.suffix().compare( QStringLiteral( "py" ), Qt::CaseInsensitive ) == 0 )
if ( fileInfo.suffix().compare( QLatin1String( "py" ), Qt::CaseInsensitive ) == 0 )
{
return new QgsPyDataItem( parentItem, fileInfo.baseName(), path );
}
@@ -265,7 +265,7 @@ void QgsPyDropHandler::handleCustomUriDrop( const QgsMimeDataUtils::Uri &uri ) c
bool QgsPyDropHandler::handleFileDrop( const QString &file )
{
QFileInfo fi( file );
if ( fi.completeSuffix().compare( QStringLiteral( "py" ), Qt::CaseInsensitive ) == 0 )
if ( fi.completeSuffix().compare( QLatin1String( "py" ), Qt::CaseInsensitive ) == 0 )
{
QgisApp::instance()->runScript( file );
return true;
@@ -93,7 +93,7 @@ void QgsDecorationNorthArrow::run()

QString QgsDecorationNorthArrow::svgPath()
{
if ( mSvgPath.startsWith( QStringLiteral( "base64:" ), Qt::CaseInsensitive ) )
if ( mSvgPath.startsWith( QLatin1String( "base64:" ), Qt::CaseInsensitive ) )
return mSvgPath;

if ( !mSvgPath.isEmpty() )
@@ -136,7 +136,7 @@ bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems,
if ( ! username.isEmpty() )
{
// Inject credentials
if ( uri.startsWith( QStringLiteral( "PG:" ) ) )
if ( uri.startsWith( QLatin1String( "PG:" ) ) )
{
bool chopped = false;
if ( uri.endsWith( '"' ) )
@@ -159,11 +159,11 @@ bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems,
if ( chopped )
uri += '"';
}
else if ( uri.startsWith( QStringLiteral( "SDE:" ) ) )
else if ( uri.startsWith( QLatin1String( "SDE:" ) ) )
{
uri = uri.replace( QRegExp( ",$" ), QStringLiteral( ",%1,%2" ).arg( username, password ) );
}
else if ( uri.startsWith( QStringLiteral( "IDB" ) ) )
else if ( uri.startsWith( QLatin1String( "IDB" ) ) )
{
bool chopped = false;
if ( uri.endsWith( '"' ) )
@@ -177,32 +177,32 @@ bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems,
if ( chopped )
uri += '"';
}
else if ( uri.startsWith( QStringLiteral( "@driver=ingres" ) ) )
else if ( uri.startsWith( QLatin1String( "@driver=ingres" ) ) )
{
uri += QStringLiteral( ",userid=%1" ).arg( username );
if ( !password.isEmpty() )
uri += QStringLiteral( ",password=%1" ).arg( password );
}
else if ( uri.startsWith( QStringLiteral( "MySQL:" ) ) )
else if ( uri.startsWith( QLatin1String( "MySQL:" ) ) )
{
uri += QStringLiteral( ",user=%1" ).arg( username );
if ( !password.isEmpty() )
uri += QStringLiteral( ",password=%1" ).arg( password );
}
else if ( uri.startsWith( QStringLiteral( "MSSQL:" ) ) )
else if ( uri.startsWith( QLatin1String( "MSSQL:" ) ) )
{
uri += QStringLiteral( ";uid=%1" ).arg( username );
uri = uri.replace( QLatin1String( ";trusted_connection=yes" ), QString() );

if ( !password.isEmpty() )
uri += QStringLiteral( ";pwd=%1" ).arg( password );
}
else if ( uri.startsWith( QStringLiteral( "OCI:" ) ) )
else if ( uri.startsWith( QLatin1String( "OCI:" ) ) )
{
// OCI:userid/password@database_instance:table,table
uri = uri.replace( QStringLiteral( "OCI:/" ), QStringLiteral( "OCI:%1/%2" ).arg( username, password ) );
}
else if ( uri.startsWith( QStringLiteral( "ODBC:" ) ) )
else if ( uri.startsWith( QLatin1String( "ODBC:" ) ) )
{
if ( password.isEmpty() )
{
@@ -213,8 +213,8 @@ bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems,
uri = uri.replace( QRegExp( "^ODBC:@?" ), "ODBC:" + username + '/' + password + '@' );
}
}
else if ( uri.startsWith( QStringLiteral( "couchdb" ) )
|| uri.startsWith( QStringLiteral( "DODS" ) )
else if ( uri.startsWith( QLatin1String( "couchdb" ) )
|| uri.startsWith( QLatin1String( "DODS" ) )
|| uri.startsWith( "http://" )
|| uri.startsWith( "/vsicurl/http://" )
|| uri.startsWith( "https://" )
@@ -1543,15 +1543,15 @@ bool QgsCompositionConverter::readXml( QgsLayoutItem *layoutItem, const QDomElem

//frame
QString frame = itemElem.attribute( QStringLiteral( "frame" ) );
layoutItem->setFrameEnabled( frame.compare( QStringLiteral( "true" ), Qt::CaseInsensitive ) == 0 ) ;
layoutItem->setFrameEnabled( frame.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 ) ;

//frame
QString background = itemElem.attribute( QStringLiteral( "background" ) );
layoutItem->setBackgroundEnabled( background.compare( QStringLiteral( "true" ), Qt::CaseInsensitive ) == 0 );
layoutItem->setBackgroundEnabled( background.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 );

//position lock for mouse moves/resizes
QString positionLock = itemElem.attribute( QStringLiteral( "positionLock" ) );
layoutItem->setLocked( positionLock.compare( QStringLiteral( "true" ), Qt::CaseInsensitive ) == 0 );
layoutItem->setLocked( positionLock.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 );

//visibility
layoutItem->setVisibility( itemElem.attribute( QStringLiteral( "visibility" ), QStringLiteral( "1" ) ) != QStringLiteral( "0" ) );
@@ -1711,7 +1711,7 @@ QgsProperty QgsCompositionConverter::readOldDataDefinedProperty( const QgsCompos

QString active = ddElem.attribute( QStringLiteral( "active" ) );
bool isActive = false;
if ( active.compare( QStringLiteral( "true" ), Qt::CaseInsensitive ) == 0 )
if ( active.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 )
{
isActive = true;
}
@@ -1720,7 +1720,7 @@ QgsProperty QgsCompositionConverter::readOldDataDefinedProperty( const QgsCompos

QString useExpr = ddElem.attribute( QStringLiteral( "useExpr" ) );
bool isExpression = false;
if ( useExpr.compare( QStringLiteral( "true" ), Qt::CaseInsensitive ) == 0 )
if ( useExpr.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 )
{
isExpression = true;
}
@@ -665,7 +665,7 @@ bool QgsLayoutItem::readXml( const QDomElement &element, const QDomDocument &doc

//position lock for mouse moves/resizes
QString positionLock = element.attribute( QStringLiteral( "positionLock" ) );
if ( positionLock.compare( QStringLiteral( "true" ), Qt::CaseInsensitive ) == 0 )
if ( positionLock.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 )
{
setLocked( true );
}
@@ -109,13 +109,13 @@ QgsLayoutItemPage::Orientation QgsLayoutItemPage::decodePageOrientation( const Q
*ok = false;

QString trimmedString = string.trimmed();
if ( trimmedString.compare( QStringLiteral( "portrait" ), Qt::CaseInsensitive ) == 0 )
if ( trimmedString.compare( QLatin1String( "portrait" ), Qt::CaseInsensitive ) == 0 )
{
if ( ok )
*ok = true;
return Portrait;
}
else if ( trimmedString.compare( QStringLiteral( "landscape" ), Qt::CaseInsensitive ) == 0 )
else if ( trimmedString.compare( QLatin1String( "landscape" ), Qt::CaseInsensitive ) == 0 )
{
if ( ok )
*ok = true;

0 comments on commit 0b4694f

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