1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-31 18:39:10 +00:00

Codefix: Clear and reserve storage when loading vectors from savegames.

This commit is contained in:
2024-11-06 13:51:26 +00:00
committed by Peter Nelson
parent b8f3d0dd68
commit d4f8453c22

View File

@@ -1297,6 +1297,11 @@ public:
default: NOT_REACHED();
}
list->clear();
if constexpr (std::is_same_v<SlStorageT, std::vector<Tvar, Tallocator>>) {
list->reserve(length);
}
/* Load each value and push to the end of the storage. */
for (size_t i = 0; i < length; i++) {
Tvar &data = list->emplace_back();