Skip to content
Permalink
Browse files

Use QString::at(0) instead of left(1), since it's more efficient

and doesn't allocate a QString
  • Loading branch information
nyalldawson committed May 15, 2016
1 parent 1c1b8aa commit 0b940cacccdc6f1087a3782624599bf8d3b7fe3c
@@ -87,7 +87,7 @@ void QgsAbout::init()
{
line = stream.readLine(); // line of text excluding '\n'
//ignore the line if it starts with a hash....
if ( line.left( 1 ) == "#" )
if ( line.at( 0 ) == '#' )
continue;
QStringList myTokens = line.split( '\t', QString::SkipEmptyParts );
lines << myTokens[0];
@@ -119,7 +119,7 @@ void QgsAbout::init()
{
line = stream.readLine(); // line of text excluding '\n'
//ignore the line if it starts with a hash....
if ( line.left( 1 ) == "#" )
if ( line.at( 0 ) == '#' )
continue;
lines += line;
}
@@ -648,7 +648,7 @@ static QVariant fcnTitle( const QVariantList& values, const QgsExpressionContext
for ( int i = 0; i < elems.size(); i++ )
{
if ( elems[i].size() > 1 )
elems[i] = elems[i].left( 1 ).toUpper() + elems[i].mid( 1 ).toLower();
elems[i] = elems[i].at( 0 ).toUpper() + elems[i].mid( 1 ).toLower();
}
return QVariant( elems.join( " " ) );
}
@@ -1027,7 +1027,7 @@ QString QgsMapLayer::capitaliseLayerName( const QString& name )
QString layerName( name );

if ( capitaliseLayerName )
layerName = layerName.left( 1 ).toUpper() + layerName.mid( 1 );
layerName = layerName.at( 0 ).toUpper() + layerName.mid( 1 );

return layerName;
}
@@ -72,7 +72,7 @@ QT_BEGIN_NAMESPACE
static QString _q_escapeIdentifier(const QString &identifier)
{
QString res = identifier;
if(!identifier.isEmpty() && identifier.left(1) != QString(QLatin1Char('"')) && identifier.right(1) != QString(QLatin1Char('"')) ) {
if(!identifier.isEmpty() && identifier.at(0) != '"' && identifier.right(1) != QString(QLatin1Char('"')) ) {
res.replace(QLatin1Char('"'), QLatin1String("\"\""));
res.prepend(QLatin1Char('"')).append(QLatin1Char('"'));
res.replace(QLatin1Char('.'), QLatin1String("\".\""));

0 comments on commit 0b940ca

Please sign in to comment.