Use const-ref in foreach if T is big or non-trivial

Criteria: Linux x86_64, sizeof(T) > 8

Change-Id: I78c2b776ff219fa1ff6632fde17ae25fae66c54e
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
Sérgio Martins 2015-07-01 17:23:10 +01:00 committed by Marc Mutz
parent 0698f876ca
commit ebe4ab04ca
9 changed files with 18 additions and 19 deletions

View File

@ -174,11 +174,10 @@ void QConnmanManagerInterface::connectNotify(const QMetaMethod &signal)
void QConnmanManagerInterface::onServicesChanged(const ConnmanMapList &changed, const QList<QDBusObjectPath> &removed)
{
ConnmanMap connmanobj;
servicesList.clear(); //connman list changes order
Q_FOREACH (connmanobj, changed) {
Q_FOREACH (const ConnmanMap &connmanobj, changed) {
const QString svcPath(connmanobj.objectPath.path());
servicesList << svcPath;
servicesList << svcPath;
}
Q_EMIT servicesChanged(changed, removed);
@ -220,7 +219,7 @@ QStringList QConnmanManagerInterface::getTechnologies()
QDBusPendingReply<ConnmanMapList> reply = call(QLatin1String("GetTechnologies"));
reply.waitForFinished();
if (!reply.isError()) {
Q_FOREACH (ConnmanMap map, reply.value()) {
Q_FOREACH (const ConnmanMap &map, reply.value()) {
if (!technologiesMap.contains(map.objectPath.path())) {
technologyAdded(map.objectPath, map.propertyMap);
}
@ -236,7 +235,7 @@ QStringList QConnmanManagerInterface::getServices()
QDBusPendingReply<ConnmanMapList> reply = call(QLatin1String("GetServices"));
reply.waitForFinished();
if (!reply.isError()) {
Q_FOREACH (ConnmanMap map, reply.value()) {
Q_FOREACH (const ConnmanMap &map, reply.value()) {
servicesList << map.objectPath.path();
}
}

View File

@ -97,7 +97,7 @@ QStringList QOfonoManagerInterface::getModems()
QDBusPendingReply<PathPropertiesList> reply = callWithArgumentList(QDBus::Block, QLatin1String("GetModems"), argumentList);
reply.waitForFinished();
if (!reply.isError()) {
foreach (ObjectPathProperties modem, reply.value()) {
foreach (const ObjectPathProperties &modem, reply.value()) {
modemList << modem.path.path();
}
}
@ -260,7 +260,7 @@ QStringList QOfonoDataConnectionManagerInterface::contexts()
QDBusPendingReply<PathPropertiesList > reply = call(QLatin1String("GetContexts"));
reply.waitForFinished();
if (!reply.isError()) {
foreach (ObjectPathProperties context, reply.value()) {
foreach (const ObjectPathProperties &context, reply.value()) {
contextList << context.path.path();
}
}

View File

@ -4589,7 +4589,7 @@ void HtmlGenerator::generateManifestFile(const QString &manifest, const QString
if (!tags.isEmpty()) {
writer.writeStartElement("tags");
bool wrote_one = false;
foreach (QString tag, tags) {
foreach (const QString &tag, tags) {
if (wrote_one)
writer.writeCharacters(",");
writer.writeCharacters(tag);

View File

@ -167,7 +167,7 @@ void QDocForest::setSearchOrder(QStringList& t)
forest_.remove(primaryName);
QMap<QString, Tree*>::iterator i;
foreach (QString m, t) {
foreach (const QString &m, t) {
if (primaryName != m) {
i = forest_.find(m);
if (i != forest_.end()) {
@ -1296,7 +1296,7 @@ void QDocDatabase::resolveNamespaces()
t = forest_.nextTree();
}
QList<QString> keys = nmm_.uniqueKeys();
foreach (QString s, keys) {
foreach (const QString &s, keys) {
NamespaceNode* ns = 0;
QList<Node*> nodes = nmm_.values(s);
int count = nmm_.remove(s);

View File

@ -183,7 +183,7 @@ void Compress::operator () (int *table, int row_count, int column_count)
index.fill (-999999, row_count);
foreach (UncompressedRow row, sortedTable)
foreach (const UncompressedRow &row, sortedTable)
{
int first_token = std::distance (row.begin (), row.beginNonZeros ());
QVector<int>::iterator pos = info.begin ();

View File

@ -163,7 +163,7 @@ void CppGenerator::operator () ()
if (item->rule == grammar.goal)
accept_state = q;
foreach (Name s, lookaheads)
foreach (const Name &s, lookaheads)
{
int &u = ACTION (q, aut.id (s));
@ -616,7 +616,7 @@ void CppGenerator::generateImpl (QTextStream &out)
out << name_ids.value(rule->lhs);
foreach (Name n, rule->rhs)
foreach (const Name &n, rule->rhs)
out << ", " << name_ids.value (n);
}
out << "};" << endl << endl;

View File

@ -367,7 +367,7 @@ void Automaton::closure (StatePointer state)
if (_M_grammar->isNonTerminal (*item->dot))
{
foreach (RulePointer rule, _M_grammar->rule_map.values (*item->dot))
foreach (const RulePointer &rule, _M_grammar->rule_map.values (*item->dot))
{
Item ii;
ii.rule = rule;
@ -413,7 +413,7 @@ void Automaton::buildLookbackSets ()
if (! _M_grammar->isNonTerminal (A))
continue;
foreach (RulePointer rule, _M_grammar->rule_map.values (A))
foreach (const RulePointer &rule, _M_grammar->rule_map.values (A))
{
StatePointer q = p;
@ -606,7 +606,7 @@ void Automaton::buildIncludesDigraph ()
if (! _M_grammar->isNonTerminal (name))
continue;
foreach (RulePointer rule, _M_grammar->rule_map.values (name))
foreach (const RulePointer &rule, _M_grammar->rule_map.values (name))
{
StatePointer p = pp;
@ -706,7 +706,7 @@ void Automaton::buildLookaheads ()
{
for (ItemPointer item = p->closure.begin (); item != p->closure.end (); ++item)
{
foreach (Lookback lookback, lookbacks.values (item))
foreach (const Lookback &lookback, lookbacks.values (item))
{
StatePointer q = lookback.state;

View File

@ -91,7 +91,7 @@ void ParseTable::operator () (Automaton *aut)
first = false;
foreach (Name la, aut->lookaheads.value (item))
foreach (const Name &la, aut->lookaheads.value (item))
out << " " << *la << " reduce using rule " << aut->id (item->rule) << " (" << *item->rule->lhs << ")" << endl;
}

View File

@ -2972,7 +2972,7 @@ void QFileDialogPrivate::createWidgets()
q->setHistory(options->history());
if (options->initiallySelectedFiles().count() == 1)
q->selectFile(options->initiallySelectedFiles().first().fileName());
foreach (QUrl url, options->initiallySelectedFiles())
foreach (const QUrl &url, options->initiallySelectedFiles())
q->selectUrl(url);
lineEdit()->selectAll();
_q_updateOkButton();