From 4ef014cb737ce0c133ada0ebf8ad25898997bcfe Mon Sep 17 00:00:00 2001 From: Herman Semenov Date: Fri, 12 Apr 2024 14:03:12 +0300 Subject: [PATCH] [Common] Fixes from Unknown W. Brackets: --- Common/Input/InputState.cpp | 2 +- Common/Serialize/SerializeList.h | 2 +- Common/UI/Root.cpp | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Common/Input/InputState.cpp b/Common/Input/InputState.cpp index e766bf2c3e..1586bedce0 100644 --- a/Common/Input/InputState.cpp +++ b/Common/Input/InputState.cpp @@ -42,7 +42,7 @@ std::vector tabRightKeys; static std::unordered_map uiFlipAnalogY; static void AppendKeys(std::vector &keys, const std::vector &newKeys) { - for (auto key : newKeys) { + for (const auto &key : newKeys) { keys.push_back(key); } } diff --git a/Common/Serialize/SerializeList.h b/Common/Serialize/SerializeList.h index db17b0870d..2a6fdcefa3 100644 --- a/Common/Serialize/SerializeList.h +++ b/Common/Serialize/SerializeList.h @@ -27,7 +27,7 @@ void DoList(PointerWrap &p, std::list &x, T &default_val) { Do(p, list_size); x.resize(list_size, default_val); - for (T elem : x) + for (T &elem : x) Do(p, elem); } diff --git a/Common/UI/Root.cpp b/Common/UI/Root.cpp index 7c0dc97b5a..41dadf3d16 100644 --- a/Common/UI/Root.cpp +++ b/Common/UI/Root.cpp @@ -353,21 +353,21 @@ static void ProcessHeldKeys(ViewGroup *root) { double now = time_now_d(); restart: - for (const auto &hk : heldKeys) { - if (hk.triggerTime < now) { + for (std::set::iterator iter = heldKeys.begin(); iter != heldKeys.end(); ++iter) { + if (iter->triggerTime < now) { KeyInput key; - key.keyCode = hk.key; - key.deviceId = hk.deviceId; + key.keyCode = iter->key; + key.deviceId = iter->deviceId; key.flags = KEY_DOWN; KeyEvent(key, root); focusMoves.push_back(key.keyCode); // Cannot modify the current item when looping over a set, so let's do this instead. - HeldKey k = hk; - heldKeys.erase(k); - k.triggerTime = now + repeatInterval; - heldKeys.insert(k); + HeldKey hk = *iter; + heldKeys.erase(hk); + hk.triggerTime = now + repeatInterval; + heldKeys.insert(hk); goto restart; } }