aboutsummaryrefslogtreecommitdiff
path: root/src/settings.cpp
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2021-04-05 13:38:31 +0200
committerrubenwardy <rw@rubenwardy.com>2021-10-20 14:25:39 +0100
commit83e26f839d28c5d9aa75aeab7d924fcaad445007 (patch)
treeff2617af2c8d2ca1b8742c64a28bd659def66743 /src/settings.cpp
parentc3f7905d82e5b1201d81378dedde746caf0e2451 (diff)
downloadminetest-83e26f839d28c5d9aa75aeab7d924fcaad445007.tar.gz
minetest-83e26f839d28c5d9aa75aeab7d924fcaad445007.tar.bz2
minetest-83e26f839d28c5d9aa75aeab7d924fcaad445007.zip
Reserve vectors before pushing and other code quality changes (#11161)
Diffstat (limited to 'src/settings.cpp')
-rw-r--r--src/settings.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/settings.cpp b/src/settings.cpp
index 3415ff818..cff393e5f 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -43,11 +43,11 @@ std::unordered_map<std::string, const FlagDesc *> Settings::s_flags;
Settings *Settings::createLayer(SettingsLayer sl, const std::string &end_tag)
{
if ((int)sl < 0 || sl >= SL_TOTAL_COUNT)
- throw new BaseException("Invalid settings layer");
+ throw BaseException("Invalid settings layer");
Settings *&pos = s_layers[(size_t)sl];
if (pos)
- throw new BaseException("Setting layer " + std::to_string(sl) + " already exists");
+ throw BaseException("Setting layer " + std::to_string(sl) + " already exists");
pos = new Settings(end_tag);
pos->m_settingslayer = sl;
@@ -638,6 +638,7 @@ std::vector<std::string> Settings::getNames() const
MutexAutoLock lock(m_mutex);
std::vector<std::string> names;
+ names.reserve(m_settings.size());
for (const auto &settings_it : m_settings) {
names.push_back(settings_it.first);
}