Skip to content

Commit

Permalink
SporeModManager: reserve items in SporeModManager.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 committed Jan 18, 2024
1 parent f35890d commit b403863
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions SporeModManager/SporeModManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ static bool get_sporemodinfo(const std::filesystem::path& path, const std::strin
return true;
}

static void reserve_list_items(size_t size)
{
l_SporeModInfos.reserve(size);
l_ZipFiles.reserve(size);
}

static void close_zipfiles(void)
{
for (const Zip::ZipFile& zipFile : l_ZipFiles)
Expand Down Expand Up @@ -167,6 +173,9 @@ bool SporeModManager::InstallMods(std::vector<std::filesystem::path> paths, bool
// to install the given mods
if (!skipValidation)
{
// reserve list items
reserve_list_items(paths.size());

for (size_t i = 0; i < paths.size(); i++)
{
const std::filesystem::path& path = paths[i];
Expand Down Expand Up @@ -308,6 +317,9 @@ bool SporeModManager::UpdateMods(std::vector<std::filesystem::path> paths, bool
return false;
}

// reserve list items
reserve_list_items(paths.size());

// do validation before attempting
// to update the given mods
for (size_t i = 0; i < paths.size(); i++)
Expand Down

0 comments on commit b403863

Please sign in to comment.