summaryrefslogtreecommitdiffstats
path: root/src/input/frontend/qinputaspect.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-02-29 01:01:50 +0100
committerSean Harmer <sean.harmer@kdab.com>2016-05-05 13:21:17 +0000
commita72629194293dd29ee9c9f6964ac798f985b5e61 (patch)
treef994f710a169830abb99617b75cab419ab3828c6 /src/input/frontend/qinputaspect.cpp
parent1d8efbbe1256446211d0fcf7821390012c0e537a (diff)
input/frontend: 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 ~2.2KiB (0.44%) in text size on optimized GCC 6.0 Linux AMD64 builds. Change-Id: Ieedc74c3d5d8f843dd4076b1c2d7f3de148c150a Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/input/frontend/qinputaspect.cpp')
-rw-r--r--src/input/frontend/qinputaspect.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/input/frontend/qinputaspect.cpp b/src/input/frontend/qinputaspect.cpp
index d74938240..3bf392b06 100644
--- a/src/input/frontend/qinputaspect.cpp
+++ b/src/input/frontend/qinputaspect.cpp
@@ -142,8 +142,8 @@ QInputAspect::QInputAspect(QObject *parent)
void QInputAspectPrivate::loadInputDevicePlugins()
{
- QStringList keys = QInputDeviceIntegrationFactory::keys();
- Q_FOREACH (const QString &key, keys) {
+ const QStringList keys = QInputDeviceIntegrationFactory::keys();
+ for (const QString &key : keys) {
Qt3DInput::QInputDeviceIntegration *integration = QInputDeviceIntegrationFactory::create(key, QStringList());
if (integration != nullptr) {
m_inputHandler->addInputDeviceIntegration(integration);
@@ -160,12 +160,12 @@ void QInputAspectPrivate::loadInputDevicePlugins()
QAbstractPhysicalDevice *QInputAspect::createPhysicalDevice(const QString &name)
{
Q_D(QInputAspect);
- QAbstractPhysicalDevice *device = nullptr;
- Q_FOREACH (Qt3DInput::QInputDeviceIntegration *integration, d->m_inputHandler->inputDeviceIntegrations()) {
- if ((device = integration->createPhysicalDevice(name)) != nullptr)
- break;
+ const auto integrations = d->m_inputHandler->inputDeviceIntegrations();
+ for (Qt3DInput::QInputDeviceIntegration *integration : integrations) {
+ if (auto dev = integration->createPhysicalDevice(name))
+ return dev;
}
- return device;
+ return nullptr;
}
QStringList QInputAspect::availablePhysicalDevices() const
@@ -189,7 +189,8 @@ QVector<QAspectJobPtr> QInputAspect::jobsToExecute(qint64 time)
jobs.append(d->m_inputHandler->keyboardJobs());
jobs.append(d->m_inputHandler->mouseJobs());
- Q_FOREACH (QInputDeviceIntegration *integration, d->m_inputHandler->inputDeviceIntegrations())
+ const auto integrations = d->m_inputHandler->inputDeviceIntegrations();
+ for (QInputDeviceIntegration *integration : integrations)
jobs += integration->jobsToExecute(time);
// All the jobs added up until this point are independents
@@ -197,10 +198,11 @@ QVector<QAspectJobPtr> QInputAspect::jobsToExecute(qint64 time)
const QVector<QAspectJobPtr> dependsOnJobs = jobs;
// Jobs that update Axis/Action (store combined axis/action value)
- Q_FOREACH (Input::HLogicalDevice devHandle, d->m_inputHandler->logicalDeviceManager()->activeDevices()) {
+ const auto devHandles = d->m_inputHandler->logicalDeviceManager()->activeDevices();
+ for (Input::HLogicalDevice devHandle : devHandles) {
QAspectJobPtr updateAxisActionJob(new Input::UpdateAxisActionJob(time, d->m_inputHandler.data(), devHandle));
jobs += updateAxisActionJob;
- Q_FOREACH (const QAspectJobPtr job, dependsOnJobs)
+ for (const QAspectJobPtr &job : dependsOnJobs)
updateAxisActionJob->addDependency(job);
}