1
0
Fork 0

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

pull/13096/head
Peter Nelson 2024-11-06 13:51:26 +00:00 committed by Peter Nelson
parent b8f3d0dd68
commit d4f8453c22
1 changed files with 5 additions and 0 deletions

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();