From a22cc615a97a0e7d55f44e8d14428418def58e2d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 27 May 2019 12:37:43 -0400 Subject: [PATCH] UICommon/ResourcePack: Remove unnecessary resizes We can simply construct the containers with the desired size in these cases. --- .../UICommon/ResourcePack/ResourcePack.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/Source/Core/UICommon/ResourcePack/ResourcePack.cpp b/Source/Core/UICommon/ResourcePack/ResourcePack.cpp index 4f4169d053..29bf41c9e0 100644 --- a/Source/Core/UICommon/ResourcePack/ResourcePack.cpp +++ b/Source/Core/UICommon/ResourcePack/ResourcePack.cpp @@ -68,13 +68,9 @@ ResourcePack::ResourcePack(const std::string& path) : m_path(path) } unz_file_info manifest_info; - unzGetCurrentFileInfo(file, &manifest_info, nullptr, 0, nullptr, 0, nullptr, 0); - std::vector manifest_contents; - - manifest_contents.resize(manifest_info.uncompressed_size); - + std::vector manifest_contents(manifest_info.uncompressed_size); if (!ReadCurrentFileUnlimited(file, manifest_contents)) { m_valid = false; @@ -114,13 +110,10 @@ ResourcePack::ResourcePack(const std::string& path) : m_path(path) do { - std::string filename; - - filename.resize(256); + std::string filename(256, '\0'); unz_file_info texture_info; - - unzGetCurrentFileInfo(file, &texture_info, &filename[0], static_cast(filename.size()), + unzGetCurrentFileInfo(file, &texture_info, filename.data(), static_cast(filename.size()), nullptr, 0, nullptr, 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; - unzGetCurrentFileInfo(file, &texture_info, nullptr, 0, nullptr, 0, nullptr, 0); - std::vector data; - data.resize(texture_info.uncompressed_size); - + std::vector data(texture_info.uncompressed_size); if (!ReadCurrentFileUnlimited(file, data)) { m_error = "Failed to read texture " + texture;