Replace Map::find with Map::contains where appropriate.

This commit is contained in:
Stephen Anthony 2024-06-14 18:51:58 -02:30
parent 207b2b81e9
commit 903f376958
10 changed files with 34 additions and 43 deletions

View File

@ -98,9 +98,7 @@ Event::Type JoyMap::get(const EventMode mode, const int button,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool JoyMap::check(const JoyMapping& mapping) const
{
const auto find = myMap.find(mapping);
return (find != myMap.end());
return myMap.contains(mapping);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -122,9 +122,7 @@ Event::Type KeyMap::get(const EventMode mode, const int key, const int mod) cons
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool KeyMap::check(const Mapping& mapping) const
{
const auto find = myMap.find(convertMod(mapping));
return (find != myMap.end());
return myMap.contains(convertMod(mapping));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -714,33 +714,33 @@ EventMode PhysicalJoystickHandler::getEventMode(const Event::Type event,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalJoystickHandler::isJoystickEvent(const Event::Type event)
{
return LeftJoystickEvents.find(event) != LeftJoystickEvents.end()
|| QTJoystick3Events.find(event) != QTJoystick3Events.end()
|| RightJoystickEvents.find(event) != RightJoystickEvents.end()
|| QTJoystick4Events.find(event) != QTJoystick4Events.end();
return LeftJoystickEvents.contains(event)
|| QTJoystick3Events.contains(event)
|| RightJoystickEvents.contains(event)
|| QTJoystick4Events.contains(event);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalJoystickHandler::isPaddleEvent(const Event::Type event)
{
return LeftPaddlesEvents.find(event) != LeftPaddlesEvents.end()
|| QTPaddles3Events.find(event) != QTPaddles3Events.end()
|| RightPaddlesEvents.find(event) != RightPaddlesEvents.end()
|| QTPaddles4Events.find(event) != QTPaddles4Events.end();
return LeftPaddlesEvents.contains(event)
|| QTPaddles3Events.contains(event)
|| RightPaddlesEvents.contains(event)
|| QTPaddles4Events.contains(event);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalJoystickHandler::isKeyboardEvent(const Event::Type event)
{
return LeftKeyboardEvents.find(event) != LeftKeyboardEvents.end()
|| RightKeyboardEvents.find(event) != RightKeyboardEvents.end();
return LeftKeyboardEvents.contains(event)
|| RightKeyboardEvents.contains(event);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalJoystickHandler::isDrivingEvent(const Event::Type event)
{
return LeftDrivingEvents.find(event) != LeftDrivingEvents.end()
|| RightDrivingEvents.find(event) != RightDrivingEvents.end();
return LeftDrivingEvents.contains(event)
|| RightDrivingEvents.contains(event);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -446,33 +446,33 @@ EventMode PhysicalKeyboardHandler::getEventMode(const Event::Type event,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalKeyboardHandler::isJoystickEvent(const Event::Type event)
{
return LeftJoystickEvents.find(event) != LeftJoystickEvents.end()
|| QTJoystick3Events.find(event) != QTJoystick3Events.end()
|| RightJoystickEvents.find(event) != RightJoystickEvents.end()
|| QTJoystick4Events.find(event) != QTJoystick4Events.end();
return LeftJoystickEvents.contains(event)
|| QTJoystick3Events.contains(event)
|| RightJoystickEvents.contains(event)
|| QTJoystick4Events.contains(event);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalKeyboardHandler::isPaddleEvent(const Event::Type event)
{
return LeftPaddlesEvents.find(event) != LeftPaddlesEvents.end()
|| QTPaddles3Events.find(event) != QTPaddles3Events.end()
|| RightPaddlesEvents.find(event) != RightPaddlesEvents.end()
|| QTPaddles4Events.find(event) != QTPaddles4Events.end();
return LeftPaddlesEvents.contains(event)
|| QTPaddles3Events.contains(event)
|| RightPaddlesEvents.contains(event)
|| QTPaddles4Events.contains(event);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalKeyboardHandler::isKeyboardEvent(const Event::Type event)
{
return LeftKeyboardEvents.find(event) != LeftKeyboardEvents.end()
|| RightKeyboardEvents.find(event) != RightKeyboardEvents.end();
return LeftKeyboardEvents.contains(event)
|| RightKeyboardEvents.contains(event);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalKeyboardHandler::isDrivingEvent(const Event::Type event)
{
return LeftDrivingEvents.find(event) != LeftDrivingEvents.end()
|| RightDrivingEvents.find(event) != RightDrivingEvents.end();
return LeftDrivingEvents.contains(event)
|| RightDrivingEvents.contains(event);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -140,12 +140,11 @@ void parseCommandLine(int ac, const char* const av[],
void checkForCustomBaseDir(Settings::Options& options)
{
// If both of these are activated, the 'base in app dir' takes precedence
auto it = options.find("baseinappdir");
if(it != options.end())
if(options.contains("baseinappdir"))
OSystem::overrideBaseDirWithApp();
else
{
it = options.find("basedir");
auto it = options.find("basedir");
if(it != options.end())
OSystem::overrideBaseDir(it->second.toString());
}

View File

@ -191,8 +191,7 @@ void StellaDb::importOldPropset(const FSNode& node)
if (props.empty())
break;
if ((props.find("Cart.MD5") == props.end()) ||
props["Cart.MD5"].toString().empty())
if (!props.contains("Cart.MD5") || props["Cart.MD5"].toString().empty())
continue;
myPropertyRepository->get(props["Cart.MD5"].toString())->save(props);

View File

@ -1331,7 +1331,7 @@ string CartDebug::saveDisassembly(string path)
const bool stackUsed = (mySystem.getAccessFlags(addr|0x100) & (Device::DATA | Device::WRITE));
if (myReserved.ZPRAM[addr - 0x80] &&
myUserLabels.find(addr) == myUserLabels.end()) {
!myUserLabels.contains(addr)) {
if (addLine)
out << "\n";
out << ALIGN(16) << ourZPMnemonic[addr - 0x80] << "= $"

View File

@ -800,8 +800,7 @@ bool Debugger::isBuiltinFunction(string_view name)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::delFunction(string_view name)
{
const auto& iter = myFunctions.find(name);
if(iter == myFunctions.end())
if(!myFunctions.contains(name))
return false;
// We never want to delete built-in functions
@ -810,8 +809,7 @@ bool Debugger::delFunction(string_view name)
myFunctions.erase(string{name});
const auto& def_iter = myFunctionDefs.find(name);
if(def_iter == myFunctionDefs.end())
if(!myFunctionDefs.contains(name))
return false;
myFunctionDefs.erase(string{name});

View File

@ -169,7 +169,7 @@ bool FavoritesManager::toggleUser(string_view path)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool FavoritesManager::existsUser(string_view path) const
{
return myUserSet.find(string{path}) != myUserSet.end(); // TODO: fixed in C++20
return myUserSet.contains(string{path});
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -427,8 +427,7 @@ const string& LauncherDialog::selectedRomMD5()
myMD5List.clear();
// Lookup MD5, and if not present, cache it
const auto iter = myMD5List.find(currentNode().getPath());
if(iter == myMD5List.end())
if(!myMD5List.contains(currentNode().getPath()))
myMD5List[currentNode().getPath()] = OSystem::getROMMD5(currentNode());
return myMD5List[currentNode().getPath()];