Skip to content
Permalink
Browse files

Use more efficient QString multiple arg variant rather then

chaining .arg calls
  • Loading branch information
nyalldawson committed May 9, 2016
1 parent 239865b commit 77c4ed505474295c33386ebf631741b6bd920985
@@ -559,7 +559,7 @@ QString QgsSnappingUtils::dump()
else
limit = "not evaluated";
}
msg += QString( "index : YES | %1 | %2 | %3\n" ).arg( cachedGeoms ).arg( extentStr ).arg( limit );
msg += QString( "index : YES | %1 | %2 | %3\n" ).arg( cachedGeoms, extentStr, limit );
}
else
msg += QString( "index : ???\n" ); // should not happen
@@ -490,7 +490,7 @@ bool QgsNewGeoPackageLayerDialog::apply()

OGR_DS_Destroy( hDS );

QString uri( QString( "%1|layername=%2" ).arg( mDatabaseEdit->text() ).arg( tableName ) );
QString uri( QString( "%1|layername=%2" ).arg( mDatabaseEdit->text(), tableName ) );
QString userVisiblelayerName( layerIdentifier.isEmpty() ? tableName : layerIdentifier );
QgsVectorLayer *layer = new QgsVectorLayer( uri, userVisiblelayerName, "ogr" );
if ( layer->isValid() )
@@ -558,7 +558,9 @@ bool QgsDb2SchemaItem::handleDrop( const QMimeData* data, Qt::DropAction )
QgsDb2LayerItem* QgsDb2SchemaItem::addLayer( QgsDb2LayerProperty layerProperty, bool refresh )
{
QGis::WkbType wkbType = QgsDb2TableModel::wkbTypeFromDb2( layerProperty.type );
QString tip = tr( "DB2 *** %1 as %2 in %3" ).arg( layerProperty.geometryColName ).arg( QgsDb2TableModel::displayStringForWkbType( wkbType ) ).arg( layerProperty.srid );
QString tip = tr( "DB2 *** %1 as %2 in %3" ).arg( layerProperty.geometryColName,
QgsDb2TableModel::displayStringForWkbType( wkbType ),
layerProperty.srid );
QgsDebugMsg( tip );
QgsLayerItem::LayerType layerType;
switch ( wkbType )
@@ -225,12 +225,12 @@ QSqlDatabase QgsDb2Provider::getDatabase( const QString &connInfo, QString &errM
{
connectionString = QString( "Driver={%1};Hostname=%2;Port=%3;"
"Protocol=TCPIP;Database=%4;Uid=%5;Pwd=%6;" )
.arg( driver )
.arg( host )
.arg( driver,
host )
.arg( db.port() )
.arg( databaseName )
.arg( userName )
.arg( password );
.arg( databaseName,
userName,
password );
}
else
{
@@ -1012,9 +1012,9 @@ bool QgsDb2Provider::addFeatures( QgsFeatureList & flist )
statement += QString( "%1" ).arg( mGeometryColName );

values += QString( "db2gse.%1(CAST (%2 AS BLOB(2M)),%3)" )
.arg( mGeometryColType )
.arg( QString( "?" ) )
.arg( QString::number( mSRId ) );
.arg( mGeometryColType,
QString( "?" ),
QString::number( mSRId ) );
}

QgsDebugMsg( statement );
@@ -1230,9 +1230,9 @@ bool QgsDb2Provider::changeGeometryValues( const QgsGeometryMap &geometry_map )
query.setForwardOnly( true );

statement += QString( "db2gse.%1(CAST (%2 AS BLOB(2M)),%3)" )
.arg( mGeometryColType )
.arg( QString( "?" ) )
.arg( QString::number( mSRId ) );
.arg( mGeometryColType,
QString( "?" ),
QString::number( mSRId ) );

// set attribute filter
statement += QString( " WHERE %1=%2" ).arg( mFidColName, FID_TO_STRING( fid ) );
@@ -697,19 +697,19 @@ void QgsDb2GeomColumnTypeThread::run()
{
QString table;
table = QString( "%1[%2]" )
.arg( layerProperty.schemaName.isEmpty() ? "" : QString( "[%1]." ).arg( layerProperty.schemaName ) )
.arg( layerProperty.tableName );
.arg( layerProperty.schemaName.isEmpty() ? "" : QString( "[%1]." ).arg( layerProperty.schemaName ),
layerProperty.tableName );

QString query = QString( "SELECT %3"
" UPPER([%1].STGeometryType()),"
" [%1].STSrid"
" FROM %2"
" WHERE [%1] IS NOT NULL %4"
" GROUP BY [%1].STGeometryType(), [%1].STSrid" )
.arg( layerProperty.geometryColName )
.arg( table )
.arg( mUseEstimatedMetadata ? "TOP 1" : "" )
.arg( layerProperty.sql.isEmpty() ? "" : QString( " AND %1" ).arg( layerProperty.sql ) );
.arg( layerProperty.geometryColName,
table,
mUseEstimatedMetadata ? "TOP 1" : "",
layerProperty.sql.isEmpty() ? "" : QString( " AND %1" ).arg( layerProperty.sql ) );

// issue the sql query
QSqlDatabase db = QSqlDatabase::database( mConnectionName );
@@ -378,19 +378,19 @@ bool QgsWFSSharedData::createCache()
type = "BIGINT";
else if ( field.type() == QVariant::Double )
type = "REAL";
sql += QString( ", %1 %2" ).arg( quotedIdentifier( field.name() ) ).arg( type );
sql += QString( ", %1 %2" ).arg( quotedIdentifier( field.name() ), type );
}
sql += ")";
rc = sqlite3_exec( db, sql.toUtf8(), nullptr, nullptr, nullptr );
if ( rc != SQLITE_OK )
ret = false;

sql = QString( "SELECT AddGeometryColumn('%1','%2',0,'POLYGON',2)" ).arg( mCacheTablename ).arg( geometryFieldname );
sql = QString( "SELECT AddGeometryColumn('%1','%2',0,'POLYGON',2)" ).arg( mCacheTablename, geometryFieldname );
rc = sqlite3_exec( db, sql.toUtf8(), nullptr, nullptr, nullptr );
if ( rc != SQLITE_OK )
ret = false;

sql = QString( "SELECT CreateSpatialIndex('%1','%2')" ).arg( mCacheTablename ).arg( geometryFieldname );
sql = QString( "SELECT CreateSpatialIndex('%1','%2')" ).arg( mCacheTablename, geometryFieldname );
rc = sqlite3_exec( db, sql.toUtf8(), nullptr, nullptr, nullptr );
if ( rc != SQLITE_OK )
ret = false;

0 comments on commit 77c4ed5

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