From 6bea16b6eb34278d68ff7be2617a157a7992520b Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 5 Jun 2025 20:39:07 +1000 Subject: [PATCH] INISettingsInterface: Only set changed if the value actually changes --- src/util/ini_settings_interface.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/util/ini_settings_interface.cpp b/src/util/ini_settings_interface.cpp index 329d75961..5c4d7f3e3 100644 --- a/src/util/ini_settings_interface.cpp +++ b/src/util/ini_settings_interface.cpp @@ -206,36 +206,60 @@ bool INISettingsInterface::GetStringValue(const char* section, const char* key, void INISettingsInterface::SetIntValue(const char* section, const char* key, s32 value) { + s32 current_value; + if (GetIntValue(key, section, ¤t_value) && current_value == value) + return; + m_dirty = true; m_ini.SetValue(section, key, StringUtil::ToChars(value).c_str(), nullptr, true); } void INISettingsInterface::SetUIntValue(const char* section, const char* key, u32 value) { + u32 current_value; + if (GetUIntValue(key, section, ¤t_value) && current_value == value) + return; + m_dirty = true; m_ini.SetValue(section, key, StringUtil::ToChars(value).c_str(), nullptr, true); } void INISettingsInterface::SetFloatValue(const char* section, const char* key, float value) { + float current_value; + if (GetFloatValue(key, section, ¤t_value) && current_value == value) + return; + m_dirty = true; m_ini.SetValue(section, key, StringUtil::ToChars(value).c_str(), nullptr, true); } void INISettingsInterface::SetDoubleValue(const char* section, const char* key, double value) { + double current_value; + if (GetDoubleValue(key, section, ¤t_value) && current_value == value) + return; + m_dirty = true; m_ini.SetValue(section, key, StringUtil::ToChars(value).c_str(), nullptr, true); } void INISettingsInterface::SetBoolValue(const char* section, const char* key, bool value) { + bool current_value; + if (GetBoolValue(key, section, ¤t_value) && current_value == value) + return; + m_dirty = true; m_ini.SetBoolValue(section, key, value, nullptr, true); } void INISettingsInterface::SetStringValue(const char* section, const char* key, const char* value) { + const char* current_value = m_ini.GetValue(section, key); + if (current_value && std::strcmp(current_value, value) == 0) + return; + m_dirty = true; m_ini.SetValue(section, key, value, nullptr, true); }