CInGameTweakManagerBase: Make use of algorithms where applicable

This commit is contained in:
Lioncash 2020-04-23 20:42:28 -04:00
parent e1dfe9ff8e
commit e4dedac2b6
1 changed files with 9 additions and 8 deletions

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <algorithm>
#include <string> #include <string>
#include <vector> #include <vector>
@ -51,17 +52,17 @@ protected:
public: public:
bool HasTweakValue(std::string_view name) const { bool HasTweakValue(std::string_view name) const {
for (const CTweakValue& val : x0_values) return std::any_of(x0_values.cbegin(), x0_values.cend(),
if (val.GetName() == name) [name](const auto& value) { return value.GetName() == name; });
return true;
return false;
} }
const CTweakValue* GetTweakValue(std::string_view name) const { const CTweakValue* GetTweakValue(std::string_view name) const {
for (const CTweakValue& val : x0_values) const auto iter = std::find_if(x0_values.cbegin(), x0_values.cend(),
if (val.GetName() == name) [name](const auto& value) { return value.GetName() == name; });
return &val; if (iter == x0_values.cend()) {
return nullptr; return nullptr;
}
return &*iter;
} }
bool ReadFromMemoryCard(std::string_view name) { return true; } bool ReadFromMemoryCard(std::string_view name) { return true; }