mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Reserve vectors before pushing and other code quality changes (#11161)
This commit is contained in:
parent
3e1904fa8c
commit
f0bad0e2ba
20 changed files with 106 additions and 108 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue