refactor: use contains to find if an item is in a container

This commit is contained in:
sithlord48
2025-06-19 17:18:22 -04:00
committed by Nick Bolton
parent 07a217f54f
commit b29c5b1bb2
7 changed files with 15 additions and 15 deletions

View File

@ -90,7 +90,7 @@ bool HelloBack::shouldDowngrade(int major, int minor) const
auto versions = map.find(minor);
if (versions != map.end()) {
auto compatibleVersions = versions->second;
if (compatibleVersions.find(m_minorVersion) != compatibleVersions.end()) {
if (compatibleVersions.contains(m_minorVersion)) {
return true;
}
}

View File

@ -784,7 +784,7 @@ bool KeyMap::keysToRestoreModifiers(
// release unwanted keys
for (ModifierToKeys::const_iterator i = oldModifiers.begin(); i != oldModifiers.end(); ++i) {
KeyButton button = i->second.m_button;
if (button != keyItem.m_button && newKeys.count(button) == 0) {
if (button != keyItem.m_button && !newKeys.contains(button)) {
EKeystroke type = kKeystrokeRelease;
if (i->second.m_lock) {
type = kKeystrokeUnmodify;
@ -796,7 +796,7 @@ bool KeyMap::keysToRestoreModifiers(
// press wanted keys
for (auto i = desiredModifiers.begin(); i != desiredModifiers.end(); ++i) {
const KeyButton button = i->second.m_button;
if (button != keyItem.m_button && oldKeys.count(button) == 0) {
if (button != keyItem.m_button && !oldKeys.contains(button)) {
EKeystroke type = kKeystrokePress;
if (i->second.m_lock) {
type = kKeystrokeModify;
@ -943,7 +943,7 @@ void KeyMap::addKeystrokes(
}
// if no more keys for this modifier then deactivate modifier
if (activeModifiers.count(keyItem.m_generates) == 0) {
if (!activeModifiers.contains(keyItem.m_generates)) {
currentState &= ~keyItem.m_generates;
}
}
@ -965,7 +965,7 @@ void KeyMap::addKeystrokes(
case kKeystrokeUnmodify:
if (keyItem.m_lock) {
// we assume there's just one button for this modifier
if (m_halfDuplex.count(button) > 0) {
if (m_halfDuplex.contains(button)) {
if (type == kKeystrokeModify) {
// turn half-duplex toggle on (press)
keystrokes.push_back(Keystroke(button, true, false, data));
@ -1084,13 +1084,13 @@ std::string KeyMap::formatKey(KeyID key, KeyModifierMask mask)
std::string x;
for (int32_t i = 0; i < kKeyModifierNumBits; ++i) {
KeyModifierMask mod = (1u << i);
if ((mask & mod) != 0 && s_modifierToNameMap->count(mod) > 0) {
if ((mask & mod) != 0 && s_modifierToNameMap->contains(mod)) {
x += s_modifierToNameMap->find(mod)->second;
x += "+";
}
}
if (key != kKeyNone) {
if (s_keyToNameMap->count(key) > 0) {
if (s_keyToNameMap->contains(key)) {
x += s_keyToNameMap->find(key)->second;
}
// XXX -- we're assuming ASCII here
@ -1113,7 +1113,7 @@ bool KeyMap::parseKey(const std::string &x, KeyID &key)
// parse the key
key = kKeyNone;
if (s_nameToKeyMap->count(x) > 0) {
if (s_nameToKeyMap->contains(x)) {
key = s_nameToKeyMap->find(x)->second;
}
// XXX -- we're assuming ASCII encoding here
@ -1157,7 +1157,7 @@ bool KeyMap::parseModifiers(std::string &x, KeyModifierMask &mask)
return false;
}
if (s_nameToModifierMap->count(c) > 0) {
if (s_nameToModifierMap->contains(c)) {
KeyModifierMask mod = s_nameToModifierMap->find(c)->second;
if ((mask & mod) != 0) {
// modifier appears twice

View File

@ -924,7 +924,7 @@ bool KeyState::fakeKeyUp(KeyButton serverID)
++i;
m_activeModifiers.erase(tmp);
if (m_activeModifiers.count(mask) == 0) {
if (!m_activeModifiers.contains(mask)) {
// no key for modifier is down so deactivate modifier
m_mask &= ~mask;
LOG((CLOG_DEBUG1 "new state %04x", m_mask));

View File

@ -814,7 +814,7 @@ void XWindowsClipboard::insertReply(Reply *reply)
// find the right reply when handling property notify events we stick
// to just the requestor.
const bool newWindow = (m_replies.count(reply->m_requestor) == 0);
const bool newWindow = !m_replies.contains(reply->m_requestor);
m_replies[reply->m_requestor].push_back(reply);
// adjust requestor's event mask if we haven't done so already. we

View File

@ -481,7 +481,7 @@ void XWindowsKeyState::updateKeysymMap(deskflow::KeyMap &keyMap)
for (int j = 0; j < maxKeysyms; ++j) {
item.m_id = XWindowsUtil::mapKeySymToKeyID(keysyms[j]);
if (item.m_id == kKeyNone) {
if (j != 0 && modifierButtons.count(keycode) > 0) {
if (j != 0 && modifierButtons.contains(keycode)) {
// pretend the modifier works in other shift levels
// because it probably does.
if (keysyms[1] == NoSymbol || j != 3) {
@ -509,7 +509,7 @@ void XWindowsKeyState::updateKeysymMap(deskflow::KeyMap &keyMap)
item.m_generates = 0;
item.m_lock = false;
if (modifierButtons.count(keycode) > 0) {
if (modifierButtons.contains(keycode)) {
// get flags for modifier keys
deskflow::KeyMap::initModifierKey(item);

View File

@ -1175,7 +1175,7 @@ void XWindowsScreen::handleSystemEvent(const Event &event)
// discard matching key releases for key presses that were
// filtered and remove them from our filtered list.
else if (xevent->type == KeyRelease && m_filtered.count(xevent->xkey.keycode) > 0) {
else if (xevent->type == KeyRelease && m_filtered.contains(xevent->xkey.keycode)) {
m_filtered.erase(xevent->xkey.keycode);
return;
}

View File

@ -1203,7 +1203,7 @@ void Server::handleClipboardGrabbed(const Event &event, BaseClientProxy *grabber
void Server::handleClipboardChanged(const Event &event, BaseClientProxy *client)
{
// ignore events from unknown clients
if (m_clientSet.count(client) == 0) {
if (!m_clientSet.contains(client)) {
return;
}
const auto *info = static_cast<const IScreen::ClipboardInfo *>(event.getData());