summaryrefslogtreecommitdiffstats
path: root/src/core/aspects
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-02-29 01:01:50 +0100
committerMarc Mutz <marc.mutz@kdab.com>2016-02-29 10:35:02 +0000
commite484d72a00225ffd71c5dc356f66e2d73c06b823 (patch)
tree661ef3f174a806e2d95ca87e1dcf7d85dcb2c563 /src/core/aspects
parentf6f337aff7c78ed8192442e2062bc08a1a00c2b2 (diff)
core: eradicate Q_FOREACH loops [low-risk]
... by replacing them with C++11 range-for loops. To avoid detaches of these mutable Qt containers, wrap the container in qAsConst(), where needed. 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. Saves 8.3KiB (2.8%) in text size on optimized GCC 5.3 Linux AMD64 builds. Change-Id: I5fae547c8a3a0a4c5467b967da55470d353f0ba8 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/core/aspects')
-rw-r--r--src/core/aspects/qaspectengine.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/core/aspects/qaspectengine.cpp b/src/core/aspects/qaspectengine.cpp
index 9422a4471..9fca7b985 100644
--- a/src/core/aspects/qaspectengine.cpp
+++ b/src/core/aspects/qaspectengine.cpp
@@ -88,7 +88,8 @@ void QAspectEnginePrivate::initNode(QNode *node)
void QAspectEnginePrivate::initEntity(QEntity *entity)
{
- Q_FOREACH (QComponent *comp, entity->components()) {
+ const auto components = entity->components();
+ for (QComponent *comp : components) {
if (!m_scene->hasEntityForComponent(comp->id(), entity->id())) {
if (!comp->isShareable() && !m_scene->entitiesForComponent(comp->id()).isEmpty())
qWarning() << "Trying to assign a non shareable component to more than one Entity";
@@ -213,7 +214,7 @@ QVariant QAspectEngine::executeCommand(const QString &command)
QStringList reply;
reply << QLatin1Literal("Loaded aspects:");
- foreach (QAbstractAspect *aspect, d->m_aspects) {
+ for (QAbstractAspect *aspect : qAsConst(d->m_aspects)) {
const QString name = d->m_factory.aspectName(aspect);
if (!name.isEmpty())
reply << (QLatin1Literal(" * ") + name);
@@ -226,7 +227,7 @@ QVariant QAspectEngine::executeCommand(const QString &command)
QStringList args = command.split(QLatin1Char(' '));
QString aspectName = args.takeFirst();
- foreach (QAbstractAspect *aspect, d->m_aspects) {
+ for (QAbstractAspect *aspect : qAsConst(d->m_aspects)) {
if (aspectName == d->m_factory.aspectName(aspect))
return aspect->executeCommand(args);
}