Skip to content

Commit 0b940ca

Browse files
committedMay 15, 2016
Use QString::at(0) instead of left(1), since it's more efficient
and doesn't allocate a QString
1 parent 1c1b8aa commit 0b940ca

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed
 

‎src/app/qgsabout.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void QgsAbout::init()
8787
{
8888
line = stream.readLine(); // line of text excluding '\n'
8989
//ignore the line if it starts with a hash....
90-
if ( line.left( 1 ) == "#" )
90+
if ( line.at( 0 ) == '#' )
9191
continue;
9292
QStringList myTokens = line.split( '\t', QString::SkipEmptyParts );
9393
lines << myTokens[0];
@@ -119,7 +119,7 @@ void QgsAbout::init()
119119
{
120120
line = stream.readLine(); // line of text excluding '\n'
121121
//ignore the line if it starts with a hash....
122-
if ( line.left( 1 ) == "#" )
122+
if ( line.at( 0 ) == '#' )
123123
continue;
124124
lines += line;
125125
}

‎src/core/qgsexpression.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ static QVariant fcnTitle( const QVariantList& values, const QgsExpressionContext
648648
for ( int i = 0; i < elems.size(); i++ )
649649
{
650650
if ( elems[i].size() > 1 )
651-
elems[i] = elems[i].left( 1 ).toUpper() + elems[i].mid( 1 ).toLower();
651+
elems[i] = elems[i].at( 0 ).toUpper() + elems[i].mid( 1 ).toLower();
652652
}
653653
return QVariant( elems.join( " " ) );
654654
}

‎src/core/qgsmaplayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ QString QgsMapLayer::capitaliseLayerName( const QString& name )
10271027
QString layerName( name );
10281028

10291029
if ( capitaliseLayerName )
1030-
layerName = layerName.left( 1 ).toUpper() + layerName.mid( 1 );
1030+
layerName = layerName.at( 0 ).toUpper() + layerName.mid( 1 );
10311031

10321032
return layerName;
10331033
}

‎src/providers/spatialite/qspatialite/qsql_spatialite.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ QT_BEGIN_NAMESPACE
7272
static QString _q_escapeIdentifier(const QString &identifier)
7373
{
7474
QString res = identifier;
75-
if(!identifier.isEmpty() && identifier.left(1) != QString(QLatin1Char('"')) && identifier.right(1) != QString(QLatin1Char('"')) ) {
75+
if(!identifier.isEmpty() && identifier.at(0) != '"' && identifier.right(1) != QString(QLatin1Char('"')) ) {
7676
res.replace(QLatin1Char('"'), QLatin1String("\"\""));
7777
res.prepend(QLatin1Char('"')).append(QLatin1Char('"'));
7878
res.replace(QLatin1Char('.'), QLatin1String("\".\""));

0 commit comments

Comments
 (0)
Please sign in to comment.