[Common] Fixes from Unknown W. Brackets: <checkins@unknownbrackets.org>

This commit is contained in:
Herman Semenov 2024-04-12 14:03:12 +03:00 committed by Henrik Rydgård
parent efa742322b
commit 4ef014cb73
3 changed files with 10 additions and 10 deletions

View File

@ -42,7 +42,7 @@ std::vector<InputMapping> tabRightKeys;
static std::unordered_map<InputDeviceID, int> uiFlipAnalogY;
static void AppendKeys(std::vector<InputMapping> &keys, const std::vector<InputMapping> &newKeys) {
for (auto key : newKeys) {
for (const auto &key : newKeys) {
keys.push_back(key);
}
}

View File

@ -27,7 +27,7 @@ void DoList(PointerWrap &p, std::list<T> &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);
}

View File

@ -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<HeldKey>::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;
}
}