* Prevent a possible C++11 range for detach

The solution with Qt>=5.7 is to use the qAsConst() macro.
But the qAsConst macro is just a const_cast to const T&.

* Don't call QByteArray::operator[]() on temporary

Just use the QByteArray::at().

* Adds missing reference in foreach

That's an non non trivial type (QString), using a reference as no drawbacks
and it performs better.

* Use QStringList::constFirst()

Drop QStringList::first(). It's faster and we might avoid detaching a
temporary.

* Don't call QList::operator[]() on temporary objects

It's not what we want. The at operator and QList::value() do the job in the
right way.

* Stops allocating an unneeded temporary container

We were allocating an temporary container (_entries.values(keyCode)) which
implies an extra iteration also.
Now we don't use any temporary container and only perform one iteration.
This commit is contained in:
Luís Pereira
2017-04-22 10:55:16 +01:00
committed by Alf Gaida
parent 1f7f9f8b8d
commit 3ce71a3650
5 changed files with 16 additions and 14 deletions
+3 -2
View File
@@ -96,8 +96,9 @@ QStringList ShellCommand::expand(const QStringList & items)
{
QStringList result;
foreach( QString item , items )
result << expand(item);
foreach(const QString &item, items ) {
result << expand(item);
}
return result;
}