diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-08-19 14:25:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-19 14:25:35 +0200 |
commit | 7528986e4449febead9b18b6118f0b096f7cf800 (patch) | |
tree | 8e526c1403ba8d0689ab40a24165fc19d8a07e27 /src/settings.cpp | |
parent | 1992db1395d9c068327a7c08bac7a24ef7112274 (diff) | |
download | minetest-7528986e4449febead9b18b6118f0b096f7cf800.tar.gz minetest-7528986e4449febead9b18b6118f0b096f7cf800.tar.bz2 minetest-7528986e4449febead9b18b6118f0b096f7cf800.zip |
Code modernization: src/p*, src/q*, src/r*, src/s* (partial) (#6282)
* Code modernization: src/p*, src/q*, src/r*, src/s* (partial)
* empty function
* default constructor/destructor
* for range-based loops
* use emplace_back instead of push_back
* C++ STL header style
* Spelling: vertice -> vertex
Diffstat (limited to 'src/settings.cpp')
-rw-r--r-- | src/settings.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/settings.cpp b/src/settings.cpp index 1fa4ac528..ea54ab348 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -169,9 +169,8 @@ void Settings::writeLines(std::ostream &os, u32 tab_depth) const { MutexAutoLock lock(m_mutex); - for (SettingEntries::const_iterator it = m_settings.begin(); - it != m_settings.end(); ++it) - printEntry(os, it->first, it->second, tab_depth); + for (const auto &setting_it : m_settings) + printEntry(os, setting_it.first, setting_it.second, tab_depth); } @@ -323,7 +322,7 @@ bool Settings::parseCommandLine(int argc, char *argv[], ValueType type = n->second.type; - std::string value = ""; + std::string value; if (type == VALUETYPE_FLAG) { value = "true"; @@ -506,7 +505,7 @@ bool Settings::getNoiseParamsFromValue(const std::string &name, np.persist = stof(f.next(",")); std::string optional_params = f.next(""); - if (optional_params != "") + if (!optional_params.empty()) np.lacunarity = stof(optional_params); return true; @@ -549,9 +548,8 @@ bool Settings::exists(const std::string &name) const std::vector<std::string> Settings::getNames() const { std::vector<std::string> names; - for (SettingEntries::const_iterator i = m_settings.begin(); - i != m_settings.end(); ++i) { - names.push_back(i->first); + for (const auto &settings_it : m_settings) { + names.push_back(settings_it.first); } return names; } @@ -861,9 +859,9 @@ bool Settings::remove(const std::string &name) delete it->second.group; m_settings.erase(it); return true; - } else { - return false; } + + return false; } @@ -887,8 +885,7 @@ void Settings::updateValue(const Settings &other, const std::string &name) MutexAutoLock lock(m_mutex); try { - std::string val = other.get(name); - m_settings[name] = val; + m_settings[name] = other.get(name); } catch (SettingNotFoundException &e) { } } @@ -965,7 +962,7 @@ void Settings::registerChangedCallback(const std::string &name, SettingsChangedCallback cbf, void *userdata) { MutexAutoLock lock(m_callback_mutex); - m_callbacks[name].push_back(std::make_pair(cbf, userdata)); + m_callbacks[name].emplace_back(cbf, userdata); } void Settings::deregisterChangedCallback(const std::string &name, |