Skip to content

Commit

Permalink
Use QString::arg multi argument method to avoid extra heap allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 15, 2015
1 parent f50e1a7 commit 5ed3d1b
Show file tree
Hide file tree
Showing 191 changed files with 1,182 additions and 1,172 deletions.
2 changes: 1 addition & 1 deletion python/core/qgsfield.sip
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class QgsField
if ( !sipRes )
{
PyErr_SetString(PyExc_ValueError,
QString( "Value %1 (%2) could not be converted to field type %3." ).arg( a0->toString() ).arg ( a0->typeName() ).arg( sipCpp->type() ).toUtf8().constData() );
QString( "Value %1 (%2) could not be converted to field type %3." ).arg( a0->toString(), a0->typeName() ).arg( sipCpp->type() ).toUtf8().constData() );
sipError = sipErrorFail;
}

Expand Down
6 changes: 3 additions & 3 deletions src/analysis/openstreetmap/qgsosmdatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ bool QgsOSMDatabase::prepareStatements()
{
const char* errMsg = sqlite3_errmsg( mDatabase ); // does not require free
mError = QString( "Error preparing SQL command:\n%1\nSQL:\n%2" )
.arg( QString::fromUtf8( errMsg ) ).arg( QString::fromUtf8( sql[i] ) );
.arg( QString::fromUtf8( errMsg ), QString::fromUtf8( sql[i] ) );
return false;
}
}
Expand Down Expand Up @@ -348,8 +348,8 @@ bool QgsOSMDatabase::createSpatialTable( const QString& tableName, const QString
}

QString sqlAddGeomColumn = QString( "SELECT AddGeometryColumn(%1, 'geometry', 4326, %2, 'XY')" )
.arg( quotedValue( tableName ) )
.arg( quotedValue( geometryType ) );
.arg( quotedValue( tableName ),
quotedValue( geometryType ) );
ret = sqlite3_exec( mDatabase, sqlAddGeomColumn.toUtf8().constData(), NULL, NULL, &errMsg );
if ( ret != SQLITE_OK )
{
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/openstreetmap/qgsosmimport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ bool QgsOSMXmlImport::createDatabase()
if ( sqlite3_exec( mDatabase, sqlInitStatements[i], 0, 0, &errMsg ) != SQLITE_OK )
{
mError = QString( "Error executing SQL command:\n%1\nSQL:\n%2" )
.arg( QString::fromUtf8( errMsg ) ).arg( QString::fromUtf8( sqlInitStatements[i] ) );
.arg( QString::fromUtf8( errMsg ), QString::fromUtf8( sqlInitStatements[i] ) );
sqlite3_free( errMsg );
closeDatabase();
return false;
Expand Down Expand Up @@ -201,7 +201,7 @@ bool QgsOSMXmlImport::createDatabase()
{
const char* errMsg = sqlite3_errmsg( mDatabase ); // does not require free
mError = QString( "Error preparing SQL command:\n%1\nSQL:\n%2" )
.arg( QString::fromUtf8( errMsg ) ).arg( QString::fromUtf8( sqlInsertStatements[i] ) );
.arg( QString::fromUtf8( errMsg ), QString::fromUtf8( sqlInsertStatements[i] ) );
closeDatabase();
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions src/analysis/raster/qgsalignraster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@ bool QgsAlignRaster::checkInputParameters()
mErrorMessage = QString( "Failed to get suggested warp output.\n\n"
"File:\n%1\n\n"
"Source WKT:\n%2\n\nDestination WKT:\n%3" )
.arg( r.inputFilename )
.arg( info.mCrsWkt )
.arg( mCrsWkt );
.arg( r.inputFilename,
info.mCrsWkt,
mCrsWkt );
return false;
}

Expand Down
8 changes: 4 additions & 4 deletions src/app/composer/qgsatlascompositionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ void QgsAtlasCompositionWidget::on_mAtlasFilenamePatternEdit_editingFinished()
QMessageBox::warning( this
, tr( "Could not evaluate filename pattern" )
, tr( "Could not set filename pattern as '%1'.\nParser error:\n%2" )
.arg( mAtlasFilenamePatternEdit->text() )
.arg( atlasMap->filenamePatternErrorString() )
.arg( mAtlasFilenamePatternEdit->text(),
atlasMap->filenamePatternErrorString() )
);
}
}
Expand Down Expand Up @@ -149,8 +149,8 @@ void QgsAtlasCompositionWidget::on_mAtlasFilenameExpressionButton_clicked()
QMessageBox::warning( this
, tr( "Could not evaluate filename pattern" )
, tr( "Could not set filename pattern as '%1'.\nParser error:\n%2" )
.arg( expression )
.arg( atlasMap->filenamePatternErrorString() )
.arg( expression,
atlasMap->filenamePatternErrorString() )
);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/app/gps/qgsgpsinformationwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ void QgsGPSInformationWidget::connectGps()
}
else if ( mRadGpsd->isChecked() )
{
port = QString( "%1:%2:%3" ).arg( mGpsdHost->text() ).arg( mGpsdPort->text() ).arg( mGpsdDevice->text() );
port = QString( "%1:%2:%3" ).arg( mGpsdHost->text(), mGpsdPort->text(), mGpsdDevice->text() );
}
else if ( mRadInternal->isChecked() )
{
Expand Down Expand Up @@ -847,8 +847,8 @@ void QgsGPSInformationWidget::on_mBtnCloseFeature_clicked()
QMessageBox::information( this,
tr( "Error" ),
tr( "Could not commit changes to layer %1\n\nErrors: %2\n" )
.arg( vlayer->name() )
.arg( vlayer->commitErrors().join( "\n " ) ) );
.arg( vlayer->name(),
vlayer->commitErrors().join( "\n " ) ) );
}

vlayer->startEditing();
Expand Down Expand Up @@ -977,8 +977,8 @@ void QgsGPSInformationWidget::on_mBtnCloseFeature_clicked()
QMessageBox::information( this,
tr( "Error" ),
tr( "Could not commit changes to layer %1\n\nErrors: %2\n" )
.arg( vlayer->name() )
.arg( vlayer->commitErrors().join( "\n " ) ) );
.arg( vlayer->name(),
vlayer->commitErrors().join( "\n " ) ) );
}

vlayer->startEditing();
Expand Down
4 changes: 2 additions & 2 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ int main( int argc, char *argv[] )
}
else
{
qWarning( "loading of qgis translation failed [%s]", QString( "%1/qgis_%2" ).arg( i18nPath ).arg( myTranslationCode ).toLocal8Bit().constData() );
qWarning( "loading of qgis translation failed [%s]", QString( "%1/qgis_%2" ).arg( i18nPath, myTranslationCode ).toLocal8Bit().constData() );
}

/* Translation file for Qt.
Expand All @@ -961,7 +961,7 @@ int main( int argc, char *argv[] )
}
else
{
qWarning( "loading of qt translation failed [%s]", QString( "%1/qt_%2" ).arg( QLibraryInfo::location( QLibraryInfo::TranslationsPath ) ).arg( myTranslationCode ).toLocal8Bit().constData() );
qWarning( "loading of qt translation failed [%s]", QString( "%1/qt_%2" ).arg( QLibraryInfo::location( QLibraryInfo::TranslationsPath ), myTranslationCode ).toLocal8Bit().constData() );
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/app/ogr/qgsvectorlayersaveasdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,23 +343,23 @@ QStringList QgsVectorLayerSaveAsDialog::datasourceOptions() const
{
QComboBox* cb = mDatasourceOptionsGroupBox->findChild<QComboBox*>( it.key() );
if ( cb && !cb->itemData( cb->currentIndex() ).isNull() )
options << QString( "%1=%2" ).arg( it.key() ).arg( cb->currentText() );
options << QString( "%1=%2" ).arg( it.key(), cb->currentText() );
break;
}

case QgsVectorFileWriter::String:
{
QLineEdit* le = mDatasourceOptionsGroupBox->findChild<QLineEdit*>( it.key() );
if ( le )
options << QString( "%1=%2" ).arg( it.key() ).arg( le->text() );
options << QString( "%1=%2" ).arg( it.key(), le->text() );
break;
}

case QgsVectorFileWriter::Hidden:
{
QgsVectorFileWriter::HiddenOption *opt =
dynamic_cast<QgsVectorFileWriter::HiddenOption*>( it.value() );
options << QString( "%1=%2" ).arg( it.key() ).arg( opt->mValue );
options << QString( "%1=%2" ).arg( it.key(), opt->mValue );
break;
}
}
Expand Down Expand Up @@ -393,22 +393,22 @@ QStringList QgsVectorLayerSaveAsDialog::layerOptions() const
case QgsVectorFileWriter::Set:
{
QComboBox* cb = mLayerOptionsGroupBox->findChild<QComboBox*>( it.key() );
options << QString( "%1=%2" ).arg( it.key() ).arg( cb->currentText() );
options << QString( "%1=%2" ).arg( it.key(), cb->currentText() );
break;
}

case QgsVectorFileWriter::String:
{
QLineEdit* le = mLayerOptionsGroupBox->findChild<QLineEdit*>( it.key() );
options << QString( "%1=%2" ).arg( it.key() ).arg( le->text() );
options << QString( "%1=%2" ).arg( it.key(), le->text() );
break;
}

case QgsVectorFileWriter::Hidden:
{
QgsVectorFileWriter::HiddenOption *opt =
dynamic_cast<QgsVectorFileWriter::HiddenOption*>( it.value() );
options << QString( "%1=%2" ).arg( it.key() ).arg( opt->mValue );
options << QString( "%1=%2" ).arg( it.key(), opt->mValue );
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/openstreetmap/qgsosmexportdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void QgsOSMExportDialog::updateLayerName()
layerType = "polylines";
else
layerType = "polygons";
editLayerName->setText( QString( "%1_%2" ).arg( baseName ).arg( layerType ) );
editLayerName->setText( QString( "%1_%2" ).arg( baseName, layerType ) );
}


Expand Down
34 changes: 17 additions & 17 deletions src/app/pluginmanager/qgspluginmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ void QgsPluginManager::getCppPluginsMetadata()

for ( uint i = 0; i < pluginDir.count(); i++ )
{
QString lib = QString( "%1/%2" ).arg( myPluginDir ).arg( pluginDir[i] );
QString lib = QString( "%1/%2" ).arg( myPluginDir, pluginDir[i] );

#ifdef TESTLIB
// This doesn't work on windows and causes problems with plugins
Expand Down Expand Up @@ -354,7 +354,7 @@ void QgsPluginManager::getCppPluginsMetadata()
bool loaded = myLib->load();
if ( !loaded )
{
QgsDebugMsg( QString( "Failed to load: %1 (%2)" ).arg( myLib->fileName() ).arg( myLib->errorString() ) );
QgsDebugMsg( QString( "Failed to load: %1 (%2)" ).arg( myLib->fileName(), myLib->errorString() ) );
delete myLib;
continue;
}
Expand Down Expand Up @@ -680,15 +680,15 @@ void QgsPluginManager::showPluginDetails( QStandardItem * item )
QString errorMsg;