mirror of https://github.com/stella-emu/stella.git
Minor optimization to settings I/O.
This commit is contained in:
parent
ab8e5a59d4
commit
e015025d90
|
@ -205,11 +205,11 @@ void Settings::load(const Options& options)
|
||||||
{
|
{
|
||||||
Options fromFile = myRespository->load();
|
Options fromFile = myRespository->load();
|
||||||
for (const auto& opt: fromFile)
|
for (const auto& opt: fromFile)
|
||||||
setValue(opt.first, opt.second);
|
setValue(opt.first, opt.second, false);
|
||||||
|
|
||||||
// Apply commandline options, which override those from settings file
|
// Apply commandline options, which override those from settings file
|
||||||
for(const auto& opt: options)
|
for(const auto& opt: options)
|
||||||
setValue(opt.first, opt.second);
|
setValue(opt.first, opt.second, false);
|
||||||
|
|
||||||
// Finally, validate some settings, so the rest of the codebase
|
// Finally, validate some settings, so the rest of the codebase
|
||||||
// can assume the values are valid
|
// can assume the values are valid
|
||||||
|
@ -593,12 +593,12 @@ const Variant& Settings::value(const string& key) const
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void Settings::setValue(const string& key, const Variant& value)
|
void Settings::setValue(const string& key, const Variant& value, bool persist)
|
||||||
{
|
{
|
||||||
auto it = myPermanentSettings.find(key);
|
auto it = myPermanentSettings.find(key);
|
||||||
if(it != myPermanentSettings.end()) {
|
if(it != myPermanentSettings.end()) {
|
||||||
|
if (persist && it->second != value) myRespository->save(key, value);
|
||||||
it->second = value;
|
it->second = value;
|
||||||
myRespository->save(key, value);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
myTemporarySettings[key] = value;
|
myTemporarySettings[key] = value;
|
||||||
|
|
|
@ -88,7 +88,7 @@ class Settings
|
||||||
@param key The key of the setting
|
@param key The key of the setting
|
||||||
@param value The value to assign to the key
|
@param value The value to assign to the key
|
||||||
*/
|
*/
|
||||||
void setValue(const string& key, const Variant& value);
|
void setValue(const string& key, const Variant& value, bool persist = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Convenience methods to return specific types.
|
Convenience methods to return specific types.
|
||||||
|
|
Loading…
Reference in New Issue