Codechange: Use emplace_back instead of push_back. (#13855)

This commit is contained in:
Peter Nelson
2025-03-20 17:39:10 +00:00
committed by GitHub
parent b98a7ff303
commit 89948b941b
15 changed files with 25 additions and 31 deletions
+3 -3
View File
@@ -1903,7 +1903,7 @@ std::vector<SaveLoad> SlTableHeader(const SaveLoadTable &slt)
}
/* We don't know this field, so read to nothing. */
saveloads.push_back({std::move(key), saveload_type, ((VarType)type & SLE_FILE_TYPE_MASK) | SLE_VAR_NULL, 1, SL_MIN_VERSION, SL_MAX_VERSION, nullptr, 0, std::move(handler)});
saveloads.emplace_back(std::move(key), saveload_type, ((VarType)type & SLE_FILE_TYPE_MASK) | SLE_VAR_NULL, 1, SL_MIN_VERSION, SL_MAX_VERSION, nullptr, 0, std::move(handler));
continue;
}
@@ -1917,7 +1917,7 @@ std::vector<SaveLoad> SlTableHeader(const SaveLoadTable &slt)
Debug(sl, 1, "Field type for '{}' was expected to be 0x{:02x} but 0x{:02x} was found", key, correct_type, type);
SlErrorCorrupt("Field type is different than expected");
}
saveloads.push_back(*sld_it->second);
saveloads.emplace_back(*sld_it->second);
}
for (auto &sld : saveloads) {
@@ -2010,7 +2010,7 @@ std::vector<SaveLoad> SlCompatTableHeader(const SaveLoadTable &slt, const SaveLo
/* In old savegames there can be data we no longer care for. We
* skip this by simply reading the amount of bytes indicated and
* send those to /dev/null. */
saveloads.push_back({"", SL_NULL, GetVarFileType(slc.null_type) | SLE_VAR_NULL, slc.null_length, slc.version_from, slc.version_to, nullptr, 0, nullptr});
saveloads.emplace_back("", SL_NULL, GetVarFileType(slc.null_type) | SLE_VAR_NULL, slc.null_length, slc.version_from, slc.version_to, nullptr, 0, nullptr);
} else {
auto sld_it = key_lookup.find(slc.name);
/* If this branch triggers, it means that an entry in the
+1 -1
View File
@@ -84,7 +84,7 @@ static std::vector<SaveLoad> GetSettingsDesc(const SettingTable &settings, bool
if (is_loading && sd->flags.Test(SettingFlag::NoNetworkSync) && _networking && !_network_server) {
if (IsSavegameVersionBefore(SLV_TABLE_CHUNKS)) {
/* We don't want to read this setting, so we do need to skip over it. */
saveloads.push_back({sd->GetName(), sd->save.cmd, GetVarFileType(sd->save.conv) | SLE_VAR_NULL, sd->save.length, sd->save.version_from, sd->save.version_to, nullptr, 0, nullptr});
saveloads.emplace_back(sd->GetName(), sd->save.cmd, GetVarFileType(sd->save.conv) | SLE_VAR_NULL, sd->save.length, sd->save.version_from, sd->save.version_to, nullptr, 0, nullptr);
}
continue;
}