Skip to content
Permalink
Browse files

Flip some QStrings to QLatin1String where they may be faster

  • Loading branch information
nyalldawson committed Oct 12, 2015
1 parent 52f0b5b commit 160f172b42e37d8d1554ad1e3e9a830d7626aaba
Showing with 114 additions and 114 deletions.
  1. +1 −1 src/app/gps/qgsgpsinformationwidget.cpp
  2. +1 −1 src/app/main.cpp
  3. +3 −3 src/app/qgisapp.cpp
  4. +1 −1 src/app/qgscustomization.cpp
  5. +11 −11 src/app/qgslabelinggui.cpp
  6. +4 −4 src/app/qgsoptions.cpp
  7. +1 −1 src/app/qgsprojectproperties.cpp
  8. +4 −4 src/app/qgsrasterlayerproperties.cpp
  9. +1 −1 src/auth/identcert/qgsauthidentcertmethod.cpp
  10. +1 −1 src/auth/pkipaths/qgsauthpkipathsmethod.cpp
  11. +1 −1 src/auth/pkipkcs12/qgsauthpkcs12method.cpp
  12. +1 −1 src/browser/main.cpp
  13. +3 −3 src/core/auth/qgsauthmanager.cpp
  14. +1 −1 src/core/composer/qgscomposerpicture.cpp
  15. +20 −20 src/core/qgsapplication.cpp
  16. +2 −2 src/core/qgscoordinatereferencesystem.cpp
  17. +2 −2 src/core/qgsdatadefined.cpp
  18. +1 −1 src/core/qgsexpression.cpp
  19. +1 −1 src/core/qgslayerdefinition.cpp
  20. +1 −1 src/core/qgsmaplayer.cpp
  21. +2 −2 src/core/qgspalgeometry.h
  22. +5 −5 src/core/qgspallabeling.cpp
  23. +2 −2 src/core/qgspoint.cpp
  24. +1 −1 src/core/qgsvectorlayerlabeling.cpp
  25. +2 −2 src/core/qgsvectorlayerlabelprovider.cpp
  26. +1 −1 src/core/symbology-ng/qgssymbollayerv2utils.cpp
  27. +1 −1 src/gui/auth/qgsauthconfigselect.cpp
  28. +1 −1 src/gui/qgscollapsiblegroupbox.cpp
  29. +1 −1 src/gui/qgscolordialog.cpp
  30. +23 −23 src/gui/qgsdatadefinedbutton.cpp
  31. +1 −1 src/gui/qgsmessagebaritem.cpp
  32. +1 −1 src/gui/qgsrasterformatsaveoptionswidget.cpp
  33. +1 −1 src/gui/qgsrasterlayersaveasdialog.cpp
  34. +2 −2 src/gui/symbology-ng/qgssymbollayerv2widget.cpp
  35. +1 −1 src/plugins/georeferencer/qgsgeorefplugingui.cpp
  36. +4 −4 src/plugins/roadgraph/shortestpathwidget.cpp
  37. +1 −1 src/plugins/roadgraph/units.cpp
  38. +2 −2 src/providers/wfs/qgswfsprovider.cpp
  39. +1 −1 tests/src/core/testqgsrasterfill.cpp
@@ -414,7 +414,7 @@ void QgsGPSInformationWidget::connectGps()
}
else if ( mRadInternal->isChecked() )
{
port = QString( "internalGPS" );
port = QLatin1String( "internalGPS" );
}

mGPSPlainTextEdit->appendPlainText( tr( "Connecting..." ) );
@@ -1003,7 +1003,7 @@ int main( int argc, char *argv[] )

//set up splash screen
QString mySplashPath( QgsCustomization::instance()->splashPath() );
QPixmap myPixmap( mySplashPath + QString( "splash.png" ) );
QPixmap myPixmap( mySplashPath + QLatin1String( "splash.png" ) );
QSplashScreen *mypSplash = new QSplashScreen( myPixmap );
if ( mySettings.value( "/qgis/hideSplash" ).toBool() || myHideSplash )
{
@@ -3948,7 +3948,7 @@ bool QgisApp::fileNewFromTemplate( const QString& fileName )

void QgisApp::fileNewFromDefaultTemplate()
{
QString projectTemplate = QgsApplication::qgisSettingsDirPath() + QString( "project_default.qgs" );
QString projectTemplate = QgsApplication::qgisSettingsDirPath() + QLatin1String( "project_default.qgs" );
QString msgTxt;
if ( !projectTemplate.isEmpty() && QFile::exists( projectTemplate ) )
{
@@ -4043,7 +4043,7 @@ void QgisApp::fileOpenAfterLaunch()
return;
}

if ( !projPath.endsWith( QString( "qgs" ), Qt::CaseInsensitive ) )
if ( !projPath.endsWith( QLatin1String( "qgs" ), Qt::CaseInsensitive ) )
{
messageBar()->pushMessage( autoOpenMsgTitle,
tr( "Not valid project file: %1" ).arg( projPath ),
@@ -4063,7 +4063,7 @@ void QgisApp::fileOpenAfterLaunch()
QgsMessageBar::WARNING );
}

if ( projPath.endsWith( QString( "project_default.qgs" ) ) )
if ( projPath.endsWith( QLatin1String( "project_default.qgs" ) ) )
{
messageBar()->pushMessage( autoOpenMsgTitle,
tr( "Default template has been reopened: %1" ).arg( projPath ),
@@ -55,7 +55,7 @@ QgsCustomizationDialog::QgsCustomizationDialog( QWidget *parent, QSettings* sett
myHeaders << tr( "Object name" ) << tr( "Label" ) << tr( "Description" );
treeWidget->setHeaderLabels( myHeaders );

mLastDirSettingsName = QString( "/UI/lastCustomizationDir" );
mLastDirSettingsName = QLatin1String( "/UI/lastCustomizationDir" );
//treeWidget->hideColumn(0)
connect( buttonBox->button( QDialogButtonBox::Ok ), SIGNAL( clicked() ), this, SLOT( ok() ) );
connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) );
@@ -952,8 +952,8 @@ void QgsLabelingGui::populateDataDefinedButtons( QgsPalLayerSettings& s )

mFontCaseDDBtn->init( mLayer, s.dataDefinedProperty( QgsPalLayerSettings::FontCase ),
QgsDataDefinedButton::String,
trString + QString( "[<b>NoChange</b>|<b>Upper</b>|<br>"
"<b>Lower</b>|<b>Capitalize</b>]" ) );
trString + QLatin1String( "[<b>NoChange</b>|<b>Upper</b>|<br>"
"<b>Lower</b>|<b>Capitalize</b>]" ) );

mFontLetterSpacingDDBtn->init( mLayer, s.dataDefinedProperty( QgsPalLayerSettings::FontLetterSpacing ),
QgsDataDefinedButton::AnyType, QgsDataDefinedButton::doubleDesc() );
@@ -1016,8 +1016,8 @@ void QgsLabelingGui::populateDataDefinedButtons( QgsPalLayerSettings& s )
mShapeDrawDDBtn->registerCheckedWidget( mShapeDrawChkBx );
mShapeTypeDDBtn->init( mLayer, s.dataDefinedProperty( QgsPalLayerSettings::ShapeKind ),
QgsDataDefinedButton::String,
trString + QString( "[<b>Rectangle</b>|<b>Square</b>|<br>"
"<b>Ellipse</b>|<b>Circle</b>|<b>SVG</b>]" ) );
trString + QLatin1String( "[<b>Rectangle</b>|<b>Square</b>|<br>"
"<b>Ellipse</b>|<b>Circle</b>|<b>SVG</b>]" ) );
mShapeSVGPathDDBtn->init( mLayer, s.dataDefinedProperty( QgsPalLayerSettings::ShapeSVGFile ),
QgsDataDefinedButton::String, QgsDataDefinedButton::svgPathDesc() );
mShapeSizeTypeDDBtn->init( mLayer, s.dataDefinedProperty( QgsPalLayerSettings::ShapeSizeType ),
@@ -1063,8 +1063,8 @@ void QgsLabelingGui::populateDataDefinedButtons( QgsPalLayerSettings& s )
mShadowDrawDDBtn->registerCheckedWidget( mShadowDrawChkBx );
mShadowUnderDDBtn->init( mLayer, s.dataDefinedProperty( QgsPalLayerSettings::ShadowUnder ),
QgsDataDefinedButton::String,
trString + QString( "[<b>Lowest</b>|<b>Text</b>|<br>"
"<b>Buffer</b>|<b>Background</b>]" ) );
trString + QLatin1String( "[<b>Lowest</b>|<b>Text</b>|<br>"
"<b>Buffer</b>|<b>Background</b>]" ) );
mShadowOffsetAngleDDBtn->init( mLayer, s.dataDefinedProperty( QgsPalLayerSettings::ShadowOffsetAngle ),
QgsDataDefinedButton::AnyType, QgsDataDefinedButton::double180RotDesc() );
mShadowOffsetDDBtn->init( mLayer, s.dataDefinedProperty( QgsPalLayerSettings::ShadowOffsetDist ),
@@ -1090,9 +1090,9 @@ void QgsLabelingGui::populateDataDefinedButtons( QgsPalLayerSettings& s )
trString + "[<b>Visible</b>|<b>Whole</b>]" );
mPointQuadOffsetDDBtn->init( mLayer, s.dataDefinedProperty( QgsPalLayerSettings::OffsetQuad ),
QgsDataDefinedButton::AnyType,
tr( "int<br>" ) + QString( "[<b>0</b>=Above Left|<b>1</b>=Above|<b>2</b>=Above Right|<br>"
"<b>3</b>=Left|<b>4</b>=Over|<b>5</b>=Right|<br>"
"<b>6</b>=Below Left|<b>7</b>=Below|<b>8</b>=Below Right]" ) );
tr( "int<br>" ) + QLatin1String( "[<b>0</b>=Above Left|<b>1</b>=Above|<b>2</b>=Above Right|<br>"
"<b>3</b>=Left|<b>4</b>=Over|<b>5</b>=Right|<br>"
"<b>6</b>=Below Left|<b>7</b>=Below|<b>8</b>=Below Right]" ) );
mPointOffsetDDBtn->init( mLayer, s.dataDefinedProperty( QgsPalLayerSettings::OffsetXY ),
QgsDataDefinedButton::AnyType, QgsDataDefinedButton::doubleXYDesc() );
mPointOffsetUnitsDDBtn->init( mLayer, s.dataDefinedProperty( QgsPalLayerSettings::OffsetUnits ),
@@ -1130,8 +1130,8 @@ void QgsLabelingGui::populateDataDefinedButtons( QgsPalLayerSettings& s )
mCoordAlignmentHDDBtn->setUsageInfo( ddPlaceInfo );
mCoordAlignmentVDDBtn->init( mLayer, s.dataDefinedProperty( QgsPalLayerSettings::Vali ),
QgsDataDefinedButton::String,
trString + QString( "[<b>Bottom</b>|<b>Base</b>|<br>"
"<b>Half</b>|<b>Cap</b>|<b>Top</b>]" ) );
trString + QLatin1String( "[<b>Bottom</b>|<b>Base</b>|<br>"
"<b>Half</b>|<b>Cap</b>|<b>Top</b>]" ) );
mCoordAlignmentVDDBtn->setUsageInfo( ddPlaceInfo );
mCoordRotationDDBtn->init( mLayer, s.dataDefinedProperty( QgsPalLayerSettings::Rotation ),
QgsDataDefinedButton::AnyType, QgsDataDefinedButton::double180RotDesc() );
@@ -883,7 +883,7 @@ void QgsOptions::on_cbxProjectDefaultNew_toggled( bool checked )
{
if ( checked )
{
QString fileName = QgsApplication::qgisSettingsDirPath() + QString( "project_default.qgs" );
QString fileName = QgsApplication::qgisSettingsDirPath() + QLatin1String( "project_default.qgs" );
if ( ! QFile::exists( fileName ) )
{
QMessageBox::information( 0, tr( "Save default project" ), tr( "You must set a default project" ) );
@@ -894,7 +894,7 @@ void QgsOptions::on_cbxProjectDefaultNew_toggled( bool checked )

void QgsOptions::on_pbnProjectDefaultSetCurrent_clicked()
{
QString fileName = QgsApplication::qgisSettingsDirPath() + QString( "project_default.qgs" );
QString fileName = QgsApplication::qgisSettingsDirPath() + QLatin1String( "project_default.qgs" );
if ( QgsProject::instance()->write( QFileInfo( fileName ) ) )
{
QMessageBox::information( 0, tr( "Save default project" ), tr( "Current project saved as default" ) );
@@ -907,7 +907,7 @@ void QgsOptions::on_pbnProjectDefaultSetCurrent_clicked()

void QgsOptions::on_pbnProjectDefaultReset_clicked()
{
QString fileName = QgsApplication::qgisSettingsDirPath() + QString( "project_default.qgs" );
QString fileName = QgsApplication::qgisSettingsDirPath() + QLatin1String( "project_default.qgs" );
if ( QFile::exists( fileName ) )
{
QFile::remove( fileName );
@@ -927,7 +927,7 @@ void QgsOptions::on_pbnTemplateFolderBrowse_pressed()

void QgsOptions::on_pbnTemplateFolderReset_pressed()
{
leTemplateFolder->setText( QgsApplication::qgisSettingsDirPath() + QString( "project_templates" ) );
leTemplateFolder->setText( QgsApplication::qgisSettingsDirPath() + QLatin1String( "project_templates" ) );
}

void QgsOptions::iconSizeChanged( const QString &iconSize )
@@ -1508,7 +1508,7 @@ void QgsProjectProperties::populateEllipsoidList()
myItem.semiMinor = 0.0;
mEllipsoidList.append( myItem );

myItem.acronym = QString( "PARAMETER:6370997:6370997" );
myItem.acronym = QLatin1String( "PARAMETER:6370997:6370997" );
myItem.description = tr( "Parameters:" );
myItem.semiMajor = 6370997.0;
myItem.semiMinor = 6370997.0;
@@ -193,13 +193,13 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
if ( myRasterPyramidIterator->exists )
{
lbxPyramidResolutions->addItem( new QListWidgetItem( myPyramidPixmap,
QString::number( myRasterPyramidIterator->xDim ) + QString( " x " ) +
QString::number( myRasterPyramidIterator->xDim ) + QLatin1String( " x " ) +
QString::number( myRasterPyramidIterator->yDim ) ) );
}
else
{
lbxPyramidResolutions->addItem( new QListWidgetItem( myNoPyramidPixmap,
QString::number( myRasterPyramidIterator->xDim ) + QString( " x " ) +
QString::number( myRasterPyramidIterator->xDim ) + QLatin1String( " x " ) +
QString::number( myRasterPyramidIterator->yDim ) ) );
}
}
@@ -1038,13 +1038,13 @@ void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked()
if ( myRasterPyramidIterator->exists )
{
lbxPyramidResolutions->addItem( new QListWidgetItem( myPyramidPixmap,
QString::number( myRasterPyramidIterator->xDim ) + QString( " x " ) +
QString::number( myRasterPyramidIterator->xDim ) + QLatin1String( " x " ) +
QString::number( myRasterPyramidIterator->yDim ) ) );
}
else
{
lbxPyramidResolutions->addItem( new QListWidgetItem( myNoPyramidPixmap,
QString::number( myRasterPyramidIterator->xDim ) + QString( " x " ) +
QString::number( myRasterPyramidIterator->xDim ) + QLatin1String( " x " ) +
QString::number( myRasterPyramidIterator->yDim ) ) );
}
}
@@ -73,7 +73,7 @@ bool QgsAuthIdentCertMethod::updateNetworkRequest( QNetworkRequest &request, con
Q_UNUSED( dataprovider )

// TODO: is this too restrictive, to intercept only HTTPS connections?
if ( request.url().scheme().toLower() != QString( "https" ) )
if ( request.url().scheme().toLower() != QLatin1String( "https" ) )
{
QgsDebugMsg( QString( "Update request SSL config SKIPPED for authcfg %1: not HTTPS" ).arg( authcfg ) );
return true;
@@ -73,7 +73,7 @@ bool QgsAuthPkiPathsMethod::updateNetworkRequest( QNetworkRequest &request, cons
Q_UNUSED( dataprovider )

// TODO: is this too restrictive, to intercept only HTTPS connections?
if ( request.url().scheme().toLower() != QString( "https" ) )
if ( request.url().scheme().toLower() != QLatin1String( "https" ) )
{
QgsDebugMsg( QString( "Update request SSL config SKIPPED for authcfg %1: not HTTPS" ).arg( authcfg ) );
return true;
@@ -73,7 +73,7 @@ bool QgsAuthPkcs12Method::updateNetworkRequest( QNetworkRequest &request, const
Q_UNUSED( dataprovider )

// TODO: is this too restrictive, to intercept only HTTPS connections?
if ( request.url().scheme().toLower() != QString( "https" ) )
if ( request.url().scheme().toLower() != QLatin1String( "https" ) )
{
QgsDebugMsg( QString( "Update request SSL config SKIPPED for authcfg %1: not HTTPS" ).arg( authcfg ) );
return true;
@@ -41,7 +41,7 @@ int main( int argc, char ** argv )
|| theme == "classic"
|| theme == "nkids" )
{
theme = QString( "default" );
theme = QLatin1String( "default" );
}
a.setThemeName( theme );
a.initQgis();
@@ -129,7 +129,7 @@ bool QgsAuthManager::init( const QString& pluginPath )
{
QString pn = p->name();
int pr = 0;
if ( pn != QString( "qca-ossl" ) )
if ( pn != QLatin1String( "qca-ossl" ) )
{
pr = QCA::providerPriority( pn ) + 1;
}
@@ -632,7 +632,7 @@ bool QgsAuthManager::resetMasterPassword( const QString& newpass, const QString
// backup database of failed attempt, for inspection
authDbConnection().close();
QString errdbbackup( dbbackup );
errdbbackup.replace( QString( ".db" ), QString( "_ERROR.db" ) );
errdbbackup.replace( QLatin1String( ".db" ), QLatin1String( "_ERROR.db" ) );
QFile::rename( authenticationDbPath(), errdbbackup );
QgsDebugMsg( QString( "Master password reset FAILED: backed up failed db at %1" ).arg( errdbbackup ) );

@@ -1204,7 +1204,7 @@ bool QgsAuthManager::backupAuthenticationDatabase( QString *backuppath )
// duplicate current db file to 'qgis-auth_YYYY-MM-DD-HHMMSS.db' backup
QString datestamp( QDateTime::currentDateTime().toString( "yyyy-MM-dd-hhmmss" ) );
QString dbbackup( authenticationDbPath() );
dbbackup.replace( QString( ".db" ), QString( "_%1.db" ).arg( datestamp ) );
dbbackup.replace( QLatin1String( ".db" ), QString( "_%1.db" ).arg( datestamp ) );

if ( !QFile::copy( authenticationDbPath(), dbbackup ) )
{
@@ -426,7 +426,7 @@ void QgsComposerPicture::loadPicture( const QString &path )
{
//trying to load an invalid file or bad expression, show cross picture
mMode = SVG;
QString badFile = QString( ":/images/composer/missing_image.svg" );
QString badFile( ":/images/composer/missing_image.svg" );
mSVG.load( badFile );
if ( mSVG.isValid() )
{

2 comments on commit 160f172

@jef-n

This comment has been minimized.

Copy link
Member

@jef-n jef-n replied Oct 13, 2015

Why not simply "foo" instead of QLatin1String("foo") ?

@nyalldawson

This comment has been minimized.

Copy link
Collaborator Author

@nyalldawson nyalldawson replied Oct 13, 2015

A couple of reasons:

  • QLatin1String docs suggest that it's the safest + fastest approach
  • For Qt5 builds QLatin1String is faster than the char* overloads as the char* overloads use slower utf8 decoding but QLatin1String doesn't (see http://woboq.com/blog/qstringliteral.html)
  • it will make it much easier to identify strings which we can flip to QStringLiteral when we kick Qt4 to the kerb.
Please sign in to comment.
You can’t perform that action at this time.