UICommon/ResourcePack: Remove unnecessary resizes
We can simply construct the containers with the desired size in these cases.
This commit is contained in:
parent
57701cd988
commit
a22cc615a9
|
@ -68,13 +68,9 @@ ResourcePack::ResourcePack(const std::string& path) : m_path(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
unz_file_info manifest_info;
|
unz_file_info manifest_info;
|
||||||
|
|
||||||
unzGetCurrentFileInfo(file, &manifest_info, nullptr, 0, nullptr, 0, nullptr, 0);
|
unzGetCurrentFileInfo(file, &manifest_info, nullptr, 0, nullptr, 0, nullptr, 0);
|
||||||
|
|
||||||
std::vector<char> manifest_contents;
|
std::vector<char> manifest_contents(manifest_info.uncompressed_size);
|
||||||
|
|
||||||
manifest_contents.resize(manifest_info.uncompressed_size);
|
|
||||||
|
|
||||||
if (!ReadCurrentFileUnlimited(file, manifest_contents))
|
if (!ReadCurrentFileUnlimited(file, manifest_contents))
|
||||||
{
|
{
|
||||||
m_valid = false;
|
m_valid = false;
|
||||||
|
@ -114,13 +110,10 @@ ResourcePack::ResourcePack(const std::string& path) : m_path(path)
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
std::string filename;
|
std::string filename(256, '\0');
|
||||||
|
|
||||||
filename.resize(256);
|
|
||||||
|
|
||||||
unz_file_info texture_info;
|
unz_file_info texture_info;
|
||||||
|
unzGetCurrentFileInfo(file, &texture_info, filename.data(), static_cast<u16>(filename.size()),
|
||||||
unzGetCurrentFileInfo(file, &texture_info, &filename[0], static_cast<uint16_t>(filename.size()),
|
|
||||||
nullptr, 0, nullptr, 0);
|
nullptr, 0, nullptr, 0);
|
||||||
|
|
||||||
if (filename.compare(0, 9, "textures/") != 0 || texture_info.uncompressed_size == 0)
|
if (filename.compare(0, 9, "textures/") != 0 || texture_info.uncompressed_size == 0)
|
||||||
|
@ -215,12 +208,9 @@ bool ResourcePack::Install(const std::string& path)
|
||||||
}
|
}
|
||||||
|
|
||||||
unz_file_info texture_info;
|
unz_file_info texture_info;
|
||||||
|
|
||||||
unzGetCurrentFileInfo(file, &texture_info, nullptr, 0, nullptr, 0, nullptr, 0);
|
unzGetCurrentFileInfo(file, &texture_info, nullptr, 0, nullptr, 0, nullptr, 0);
|
||||||
|
|
||||||
std::vector<char> data;
|
std::vector<char> data(texture_info.uncompressed_size);
|
||||||
data.resize(texture_info.uncompressed_size);
|
|
||||||
|
|
||||||
if (!ReadCurrentFileUnlimited(file, data))
|
if (!ReadCurrentFileUnlimited(file, data))
|
||||||
{
|
{
|
||||||
m_error = "Failed to read texture " + texture;
|
m_error = "Failed to read texture " + texture;
|
||||||
|
|
Loading…
Reference in New Issue