Skip to content

Commit

Permalink
SporeModManager: use std::vector<char>().reserve() in Zip.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 committed Nov 21, 2023
1 parent 2f7463b commit aae742e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion SporeModManager/SporeModManagerHelpers/Zip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ using namespace SporeModManagerHelpers;
//

static std::map<std::filesystem::path, std::ifstream> l_ZipFileStreams;
static std::vector<char> l_ZipFileBuffer(UNZIP_READ_SIZE);
static std::vector<char> l_ZipFileBuffer;

//
// Local Functions
Expand Down Expand Up @@ -137,6 +137,9 @@ bool Zip::ExtractFile(ZipFile zipFile, std::filesystem::path file, std::filesyst
int bytesRead = 0;
std::ofstream outputFileStream;

// ensure the global buffer has the size reserved
l_ZipFileBuffer.reserve(UNZIP_READ_SIZE);

// try to find file in zip
if (unzLocateFile(zipFile, file.string().c_str(), 2) != UNZ_OK)
{
Expand Down Expand Up @@ -182,6 +185,9 @@ bool Zip::ExtractFile(ZipFile zipFile, std::filesystem::path file, std::vector<c
{
int bytesRead = 0;

// ensure the global buffer has the size reserved
l_ZipFileBuffer.reserve(UNZIP_READ_SIZE);

// try to find file in zip
if (unzLocateFile(zipFile, file.string().c_str(), 2) != UNZ_OK)
{
Expand Down

0 comments on commit aae742e

Please sign in to comment.