diff options
| author | Filoppi <filippotarpini@hotmail.it> | 2021-02-26 01:14:00 +0200 |
|---|---|---|
| committer | Filoppi <filippotarpini@hotmail.it> | 2021-02-26 01:14:00 +0200 |
| commit | e020b2e8ea180aa647b698eaf34354f0b6df493a (patch) | |
| tree | 11bcb5dcb2fa5d2c10c275560497138ceb12b23b /Source/Core/Common/Config | |
| parent | 1fe0953bd50088891df03c38b27cc3fd2a5196ff (diff) | |
Common: don't call OnConfigChanged() unless it has actually changed
DualShock UDP Client is the only place in the code that assumed OnConfigChanged()
is called at least once on startup or it won't load up the setting, so I took care of that
Diffstat (limited to 'Source/Core/Common/Config')
| -rw-r--r-- | Source/Core/Common/Config/Config.h | 4 | ||||
| -rw-r--r-- | Source/Core/Common/Config/Layer.h | 13 |
2 files changed, 9 insertions, 8 deletions
diff --git a/Source/Core/Common/Config/Config.h b/Source/Core/Common/Config/Config.h index e0d110719e..b5e2df7b7e 100644 --- a/Source/Core/Common/Config/Config.h +++ b/Source/Core/Common/Config/Config.h @@ -94,8 +94,8 @@ LayerType GetActiveLayerForConfig(const Info<T>& info) template <typename T> void Set(LayerType layer, const Info<T>& info, const std::common_type_t<T>& value) { - GetLayer(layer)->Set(info, value); - OnConfigChanged(); + if (GetLayer(layer)->Set(info, value)) + OnConfigChanged(); } template <typename T> diff --git a/Source/Core/Common/Config/Layer.h b/Source/Core/Common/Config/Layer.h index 5c4185cdfe..0fd80753ad 100644 --- a/Source/Core/Common/Config/Layer.h +++ b/Source/Core/Common/Config/Layer.h @@ -118,24 +118,25 @@ public: } template <typename T> - void Set(const Info<T>& config_info, const std::common_type_t<T>& value) + bool Set(const Info<T>& config_info, const std::common_type_t<T>& value) { - Set(config_info.GetLocation(), value); + return Set(config_info.GetLocation(), value); } template <typename T> - void Set(const Location& location, const T& value) + bool Set(const Location& location, const T& value) { - Set(location, ValueToString(value)); + return Set(location, ValueToString(value)); } - void Set(const Location& location, std::string new_value) + bool Set(const Location& location, std::string new_value) { const auto iter = m_map.find(location); if (iter != m_map.end() && iter->second == new_value) - return; + return false; m_is_dirty = true; m_map.insert_or_assign(location, std::move(new_value)); + return true; } void MarkAsDirty() { m_is_dirty = true; } |
