summaryrefslogtreecommitdiffstats
path: root/src/input/backend/updateaxisactionjob.cpp
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-04-30 20:52:01 +0000
commit0c03bd8409838de5a4f6323d1f07b4d29cc3e3bc (patch)
tree98f5535b2b215253a5841b6aa58ddada447d5064 /src/input/backend/updateaxisactionjob.cpp
parent2e48010cc33000e19f79f48a77612076b12720e5 (diff)
input/backend: 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 ~5.4KiB (1.08%) in text size on optimized GCC 6.0 Linux AMD64 builds. Change-Id: I8be9ac2e0d7a200d9a4a286f06f1da26377e366d Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/input/backend/updateaxisactionjob.cpp')
-rw-r--r--src/input/backend/updateaxisactionjob.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/input/backend/updateaxisactionjob.cpp b/src/input/backend/updateaxisactionjob.cpp
index 5117bba8b..741685dc8 100644
--- a/src/input/backend/updateaxisactionjob.cpp
+++ b/src/input/backend/updateaxisactionjob.cpp
@@ -54,7 +54,7 @@ namespace {
bool anyOfRequiredButtonsPressed(const QVector<int> &buttons, QAbstractPhysicalDeviceBackendNode *physicalDeviceBackend)
{
bool validButtonWasPressed = false;
- Q_FOREACH (int button, buttons) {
+ for (int button : buttons) {
if (physicalDeviceBackend->isButtonPressed(button)) {
validButtonWasPressed = true;
break;
@@ -84,13 +84,15 @@ void UpdateAxisActionJob::run()
void UpdateAxisActionJob::updateAction(LogicalDevice *device)
{
- Q_FOREACH (const Qt3DCore::QNodeId actionId, device->actions()) {
+ const auto actionIds = device->actions();
+ for (const Qt3DCore::QNodeId actionId : actionIds) {
bool actionTriggered = false;
Action *action = m_handler->actionManager()->lookupResource(actionId);
- Q_FOREACH (const Qt3DCore::QNodeId actionInputId, action->inputs()) {
+ const auto actionInputIds = action->inputs();
+ for (const Qt3DCore::QNodeId actionInputId : actionInputIds)
actionTriggered |= processActionInput(actionInputId);
- }
+
action->setActionTriggered(actionTriggered);
}
}
@@ -102,7 +104,8 @@ bool UpdateAxisActionJob::processActionInput(const Qt3DCore::QNodeId actionInput
ActionInput *actionInput = m_handler->actionInputManager()->lookupResource(actionInputId);
QAbstractPhysicalDeviceBackendNode *physicalDeviceBackend = Q_NULLPTR;
- Q_FOREACH (QInputDeviceIntegration *integration, m_handler->inputDeviceIntegrations()) {
+ const auto integrations = m_handler->inputDeviceIntegrations();
+ for (QInputDeviceIntegration *integration : integrations) {
if ((physicalDeviceBackend = integration->physicalDevice(actionInput->sourceDevice())) != Q_NULLPTR)
break;
}
@@ -122,7 +125,8 @@ bool UpdateAxisActionJob::processActionInput(const Qt3DCore::QNodeId actionInput
}
}
bool actionTriggered = false;
- Q_FOREACH (const Qt3DCore::QNodeId actionInputId, inputSequence->sequences()) {
+ const auto actionInputIds = inputSequence->sequences();
+ for (const Qt3DCore::QNodeId actionInputId : actionInputIds) {
if (processActionInput(actionInputId)){
actionTriggered |= inputSequence->actionTriggered(actionInputId, m_currentTime);
// Set the start time if it wasn't set before
@@ -142,7 +146,8 @@ bool UpdateAxisActionJob::processActionInput(const Qt3DCore::QNodeId actionInput
}
}
bool actionTriggered = false;
- Q_FOREACH (const Qt3DCore::QNodeId actionInputId, inputChord->chords()) {
+ const auto actionInputIds = inputChord->chords();
+ for (const Qt3DCore::QNodeId actionInputId : actionInputIds) {
if (processActionInput(actionInputId)){
actionTriggered |= inputChord->actionTriggered(actionInputId);
if (startTime == 0)
@@ -157,15 +162,18 @@ bool UpdateAxisActionJob::processActionInput(const Qt3DCore::QNodeId actionInput
void UpdateAxisActionJob::updateAxis(LogicalDevice *device)
{
- Q_FOREACH (const Qt3DCore::QNodeId axisId, device->axes()) {
+ const auto axisIds = device->axes();
+ for (const Qt3DCore::QNodeId axisId : axisIds) {
Axis *axis = m_handler->axisManager()->lookupResource(axisId);
float axisValue = 0.0f;
- Q_FOREACH (const Qt3DCore::QNodeId axisInputId, axis->inputs()) {
+ const auto axisInputIds = axis->inputs();
+ for (const Qt3DCore::QNodeId axisInputId : axisInputIds) {
AxisInput *axisInput = m_handler->axisInputManager()->lookupResource(axisInputId);
QAbstractPhysicalDeviceBackendNode *physicalDeviceBackend = Q_NULLPTR;
- Q_FOREACH (QInputDeviceIntegration *integration, m_handler->inputDeviceIntegrations()) {
+ const auto integrations = m_handler->inputDeviceIntegrations();
+ for (QInputDeviceIntegration *integration : integrations) {
if ((physicalDeviceBackend = integration->physicalDevice(axisInput->sourceDevice())) != Q_NULLPTR)
break;
}