Skip to content

Commit 0b4694f

Browse files
committed
More efficient case insensitive string comparison
1 parent 3014bbf commit 0b4694f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+133
-133
lines changed

src/app/dwg/qgsdwgimporter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
593593

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

596-
if ( fi.suffix().toLower() == QLatin1String( "dxf" ) )
596+
if ( fi.suffix().compare( QLatin1String( "dxf" ), Qt::CaseInsensitive ) == 0 )
597597
{
598598
//loads dxf
599599
std::unique_ptr<dxfRW> dxf( new dxfRW( drawing.toLocal8Bit() ) );
@@ -602,7 +602,7 @@ bool QgsDwgImporter::import( const QString &drawing, QString &error, bool doExpa
602602
result = DRW::BAD_UNKNOWN;
603603
}
604604
}
605-
else if ( fi.suffix().toLower() == QLatin1String( "dwg" ) )
605+
else if ( fi.suffix().compare( QLatin1String( "dwg" ), Qt::CaseInsensitive ) == 0 )
606606
{
607607
//loads dwg
608608
std::unique_ptr<dwgR> dwg( new dwgR( drawing.toLocal8Bit() ) );

src/app/layout/qgslayoutmanagerdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ QMap<QString, QString> QgsLayoutManagerDialog::templatesFromPath( const QString
190190
QFileInfoList::const_iterator infoIt = fileInfoList.constBegin();
191191
for ( ; infoIt != fileInfoList.constEnd(); ++infoIt )
192192
{
193-
if ( infoIt->suffix().toLower() == QLatin1String( "qpt" ) )
193+
if ( infoIt->suffix().compare( QLatin1String( "qpt" ), Qt::CaseInsensitive ) == 0 )
194194
{
195195
templateMap.insert( infoIt->baseName(), infoIt->absoluteFilePath() );
196196
}

src/app/qgisapp.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6201,20 +6201,20 @@ void QgisApp::openFile( const QString &fileName, const QString &fileTypeHint )
62016201
{
62026202
// check to see if we are opening a project file
62036203
QFileInfo fi( fileName );
6204-
if ( fileTypeHint == QStringLiteral( "project" ) || fi.suffix().toLower() == QLatin1String( "qgs" ) || fi.suffix().toLower() == QLatin1String( "qgz" ) )
6204+
if ( fileTypeHint == QStringLiteral( "project" ) || fi.suffix().compare( QLatin1String( "qgs" ), Qt::CaseInsensitive ) == 0 || fi.suffix().compare( QLatin1String( "qgz" ), Qt::CaseInsensitive ) == 0 )
62056205
{
62066206
QgsDebugMsg( "Opening project " + fileName );
62076207
openProject( fileName );
62086208
}
6209-
else if ( fi.suffix().toLower() == QLatin1String( "qlr" ) )
6209+
else if ( fi.suffix().compare( QLatin1String( "qlr" ), Qt::CaseInsensitive ) == 0 )
62106210
{
62116211
openLayerDefinition( fileName );
62126212
}
6213-
else if ( fi.suffix().toLower() == QLatin1String( "qpt" ) )
6213+
else if ( fi.suffix().compare( QLatin1String( "qpt" ), Qt::CaseInsensitive ) == 0 )
62146214
{
62156215
openTemplate( fileName );
62166216
}
6217-
else if ( fi.suffix().toLower() == QLatin1String( "py" ) )
6217+
else if ( fi.suffix().compare( QLatin1String( "py" ), Qt::CaseInsensitive ) == 0 )
62186218
{
62196219
runScript( fileName );
62206220
}
@@ -12790,7 +12790,7 @@ bool QgisApp::addRasterLayers( QStringList const &fileNameQStringList, bool guiW
1279012790
//time to prevent the user selecting all adfs in 1 dir which
1279112791
//actually represent 1 coverate,
1279212792

12793-
if ( myFileInfo.fileName().toLower().endsWith( QLatin1String( ".adf" ) ) )
12793+
if ( myFileInfo.fileName().endsWith( QLatin1String( ".adf" ), Qt::CaseInsensitive ) )
1279412794
{
1279512795
break;
1279612796
}

src/app/qgsaddattrdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void QgsAddAttrDialog::setPrecisionMinMax()
9393

9494
void QgsAddAttrDialog::accept()
9595
{
96-
if ( mIsShapeFile && mNameEdit->text().toLower() == QLatin1String( "shape" ) )
96+
if ( mIsShapeFile && mNameEdit->text().compare( QLatin1String( "shape" ), Qt::CaseInsensitive ) == 0 )
9797
{
9898
QMessageBox::warning( this, tr( "Add Field" ),
9999
tr( "Invalid field name. This field name is reserved and cannot be used." ) );

src/app/qgsappbrowserproviders.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ QgsDataItem *QgsQlrDataItemProvider::createDataItem( const QString &path, QgsDat
6262
{
6363
QFileInfo fileInfo( path );
6464

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

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

243-
if ( fileInfo.suffix().compare( QStringLiteral( "py" ), Qt::CaseInsensitive ) == 0 )
243+
if ( fileInfo.suffix().compare( QLatin1String( "py" ), Qt::CaseInsensitive ) == 0 )
244244
{
245245
return new QgsPyDataItem( parentItem, fileInfo.baseName(), path );
246246
}
@@ -265,7 +265,7 @@ void QgsPyDropHandler::handleCustomUriDrop( const QgsMimeDataUtils::Uri &uri ) c
265265
bool QgsPyDropHandler::handleFileDrop( const QString &file )
266266
{
267267
QFileInfo fi( file );
268-
if ( fi.completeSuffix().compare( QStringLiteral( "py" ), Qt::CaseInsensitive ) == 0 )
268+
if ( fi.completeSuffix().compare( QLatin1String( "py" ), Qt::CaseInsensitive ) == 0 )
269269
{
270270
QgisApp::instance()->runScript( file );
271271
return true;

src/app/qgsdecorationnortharrow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void QgsDecorationNorthArrow::run()
9393

9494
QString QgsDecorationNorthArrow::svgPath()
9595
{
96-
if ( mSvgPath.startsWith( QStringLiteral( "base64:" ), Qt::CaseInsensitive ) )
96+
if ( mSvgPath.startsWith( QLatin1String( "base64:" ), Qt::CaseInsensitive ) )
9797
return mSvgPath;
9898

9999
if ( !mSvgPath.isEmpty() )

src/auth/basic/qgsauthbasicmethod.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems,
136136
if ( ! username.isEmpty() )
137137
{
138138
// Inject credentials
139-
if ( uri.startsWith( QStringLiteral( "PG:" ) ) )
139+
if ( uri.startsWith( QLatin1String( "PG:" ) ) )
140140
{
141141
bool chopped = false;
142142
if ( uri.endsWith( '"' ) )
@@ -159,11 +159,11 @@ bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems,
159159
if ( chopped )
160160
uri += '"';
161161
}
162-
else if ( uri.startsWith( QStringLiteral( "SDE:" ) ) )
162+
else if ( uri.startsWith( QLatin1String( "SDE:" ) ) )
163163
{
164164
uri = uri.replace( QRegExp( ",$" ), QStringLiteral( ",%1,%2" ).arg( username, password ) );
165165
}
166-
else if ( uri.startsWith( QStringLiteral( "IDB" ) ) )
166+
else if ( uri.startsWith( QLatin1String( "IDB" ) ) )
167167
{
168168
bool chopped = false;
169169
if ( uri.endsWith( '"' ) )
@@ -177,32 +177,32 @@ bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems,
177177
if ( chopped )
178178
uri += '"';
179179
}
180-
else if ( uri.startsWith( QStringLiteral( "@driver=ingres" ) ) )
180+
else if ( uri.startsWith( QLatin1String( "@driver=ingres" ) ) )
181181
{
182182
uri += QStringLiteral( ",userid=%1" ).arg( username );
183183
if ( !password.isEmpty() )
184184
uri += QStringLiteral( ",password=%1" ).arg( password );
185185
}
186-
else if ( uri.startsWith( QStringLiteral( "MySQL:" ) ) )
186+
else if ( uri.startsWith( QLatin1String( "MySQL:" ) ) )
187187
{
188188
uri += QStringLiteral( ",user=%1" ).arg( username );
189189
if ( !password.isEmpty() )
190190
uri += QStringLiteral( ",password=%1" ).arg( password );
191191
}
192-
else if ( uri.startsWith( QStringLiteral( "MSSQL:" ) ) )
192+
else if ( uri.startsWith( QLatin1String( "MSSQL:" ) ) )
193193
{
194194
uri += QStringLiteral( ";uid=%1" ).arg( username );
195195
uri = uri.replace( QLatin1String( ";trusted_connection=yes" ), QString() );
196196

197197
if ( !password.isEmpty() )
198198
uri += QStringLiteral( ";pwd=%1" ).arg( password );
199199
}
200-
else if ( uri.startsWith( QStringLiteral( "OCI:" ) ) )
200+
else if ( uri.startsWith( QLatin1String( "OCI:" ) ) )
201201
{
202202
// OCI:userid/password@database_instance:table,table
203203
uri = uri.replace( QStringLiteral( "OCI:/" ), QStringLiteral( "OCI:%1/%2" ).arg( username, password ) );
204204
}
205-
else if ( uri.startsWith( QStringLiteral( "ODBC:" ) ) )
205+
else if ( uri.startsWith( QLatin1String( "ODBC:" ) ) )
206206
{
207207
if ( password.isEmpty() )
208208
{
@@ -213,8 +213,8 @@ bool QgsAuthBasicMethod::updateDataSourceUriItems( QStringList &connectionItems,
213213
uri = uri.replace( QRegExp( "^ODBC:@?" ), "ODBC:" + username + '/' + password + '@' );
214214
}
215215
}
216-
else if ( uri.startsWith( QStringLiteral( "couchdb" ) )
217-
|| uri.startsWith( QStringLiteral( "DODS" ) )
216+
else if ( uri.startsWith( QLatin1String( "couchdb" ) )
217+
|| uri.startsWith( QLatin1String( "DODS" ) )
218218
|| uri.startsWith( "http://" )
219219
|| uri.startsWith( "/vsicurl/http://" )
220220
|| uri.startsWith( "https://" )

src/core/layout/qgscompositionconverter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,15 +1543,15 @@ bool QgsCompositionConverter::readXml( QgsLayoutItem *layoutItem, const QDomElem
15431543

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

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

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

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

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

17211721
QString useExpr = ddElem.attribute( QStringLiteral( "useExpr" ) );
17221722
bool isExpression = false;
1723-
if ( useExpr.compare( QStringLiteral( "true" ), Qt::CaseInsensitive ) == 0 )
1723+
if ( useExpr.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 )
17241724
{
17251725
isExpression = true;
17261726
}

src/core/layout/qgslayoutitem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ bool QgsLayoutItem::readXml( const QDomElement &element, const QDomDocument &doc
665665

666666
//position lock for mouse moves/resizes
667667
QString positionLock = element.attribute( QStringLiteral( "positionLock" ) );
668-
if ( positionLock.compare( QStringLiteral( "true" ), Qt::CaseInsensitive ) == 0 )
668+
if ( positionLock.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 )
669669
{
670670
setLocked( true );
671671
}

src/core/layout/qgslayoutitempage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ QgsLayoutItemPage::Orientation QgsLayoutItemPage::decodePageOrientation( const Q
109109
*ok = false;
110110

111111
QString trimmedString = string.trimmed();
112-
if ( trimmedString.compare( QStringLiteral( "portrait" ), Qt::CaseInsensitive ) == 0 )
112+
if ( trimmedString.compare( QLatin1String( "portrait" ), Qt::CaseInsensitive ) == 0 )
113113
{
114114
if ( ok )
115115
*ok = true;
116116
return Portrait;
117117
}
118-
else if ( trimmedString.compare( QStringLiteral( "landscape" ), Qt::CaseInsensitive ) == 0 )
118+
else if ( trimmedString.compare( QLatin1String( "landscape" ), Qt::CaseInsensitive ) == 0 )
119119
{
120120
if ( ok )
121121
*ok = true;

0 commit comments

Comments
 (0)