diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-02-29 01:01:50 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2016-05-14 16:02:31 +0000 |
commit | 6cbe56dfec652d24678aeec069a22f95eb83aa2b (patch) | |
tree | c6d1d828ef858d050aa71d07366d450ebda85f9b /src/quick3d/quick3d/items | |
parent | afc5426d4a1b22df72e4cf5582c390d774768673 (diff) |
quick3d: eradicate Q_FOREACH loops [low-risk]
... by replacing them with C++11 range-for loops.
This is the batch with low-risk changes. They operate
on local containers or the loop body clearly does not
cause the container to change.
Sprinkled in a reserve() or two.
Change-Id: I5a3da485213791ae58c82f4a81829cfba558a3d6
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/quick3d/quick3d/items')
-rw-r--r-- | src/quick3d/quick3d/items/quick3dentity.cpp | 4 | ||||
-rw-r--r-- | src/quick3d/quick3d/items/quick3dnodeinstantiator.cpp | 6 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/quick3d/quick3d/items/quick3dentity.cpp b/src/quick3d/quick3d/items/quick3dentity.cpp index 2ea80b017..4eac4400e 100644 --- a/src/quick3d/quick3d/items/quick3dentity.cpp +++ b/src/quick3d/quick3d/items/quick3dentity.cpp @@ -93,8 +93,8 @@ int Quick3DEntity::qmlComponentsCount(QQmlListProperty<QComponent> *list) void Quick3DEntity::qmlClearComponents(QQmlListProperty<QComponent> *list) { Quick3DEntity *self = static_cast<Quick3DEntity *>(list->object); - QComponentVector components = self->parentEntity()->components(); - Q_FOREACH (QComponent *comp, components) { + const QComponentVector components = self->parentEntity()->components(); + for (QComponent *comp : components) { self->parentEntity()->removeComponent(comp); } } diff --git a/src/quick3d/quick3d/items/quick3dnodeinstantiator.cpp b/src/quick3d/quick3d/items/quick3dnodeinstantiator.cpp index e9b084a3d..b95290a3c 100644 --- a/src/quick3d/quick3d/items/quick3dnodeinstantiator.cpp +++ b/src/quick3d/quick3d/items/quick3dnodeinstantiator.cpp @@ -171,7 +171,8 @@ void Quick3DNodeInstantiatorPrivate::_q_modelUpdated(const QQmlChangeSet &change int difference = 0; QHash<int, QVector<QPointer<QObject> > > moved; - Q_FOREACH (const QQmlChangeSet::Change &remove, changeSet.removes()) { + const auto removes = changeSet.removes(); + for (const QQmlChangeSet::Change &remove : removes) { int index = qMin(remove.index, m_objects.count()); int count = qMin(remove.index + remove.count, m_objects.count()) - index; if (remove.isMove()) { @@ -192,7 +193,8 @@ void Quick3DNodeInstantiatorPrivate::_q_modelUpdated(const QQmlChangeSet &change difference -= remove.count; } - Q_FOREACH (const QQmlChangeSet::Change &insert, changeSet.inserts()) { + const auto inserts = changeSet.inserts(); + for (const QQmlChangeSet::Change &insert : inserts) { int index = qMin(insert.index, m_objects.count()); if (insert.isMove()) { QVector<QPointer<QObject> > movedObjects = moved.value(insert.moveId); |