UICommon/ResourcePack: Deduplicate string construction
A few cases duplicate the string patch creation, which is kind of wasteful. We can just construct the string once.
This commit is contained in:
parent
a22cc615a9
commit
157a305507
|
@ -197,9 +197,9 @@ bool ResourcePack::Install(const std::string& path)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string texture_path = path + TEXTURE_PATH + texture;
|
||||||
std::string m_full_dir;
|
std::string m_full_dir;
|
||||||
|
SplitPath(texture_path, &m_full_dir, nullptr, nullptr);
|
||||||
SplitPath(path + TEXTURE_PATH + texture, &m_full_dir, nullptr, nullptr);
|
|
||||||
|
|
||||||
if (!File::CreateFullPath(m_full_dir))
|
if (!File::CreateFullPath(m_full_dir))
|
||||||
{
|
{
|
||||||
|
@ -217,7 +217,7 @@ bool ResourcePack::Install(const std::string& path)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ofstream out(path + TEXTURE_PATH + texture, std::ios::trunc | std::ios::binary);
|
std::ofstream out(texture_path, std::ios::trunc | std::ios::binary);
|
||||||
|
|
||||||
if (!out.good())
|
if (!out.good())
|
||||||
{
|
{
|
||||||
|
@ -284,7 +284,8 @@ bool ResourcePack::Uninstall(const std::string& path)
|
||||||
if (provided_by_other_pack)
|
if (provided_by_other_pack)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (File::Exists(path + TEXTURE_PATH + texture) && !File::Delete(path + TEXTURE_PATH + texture))
|
const std::string texture_path = path + TEXTURE_PATH + texture;
|
||||||
|
if (File::Exists(texture_path) && !File::Delete(texture_path))
|
||||||
{
|
{
|
||||||
m_error = "Failed to delete texture " + texture;
|
m_error = "Failed to delete texture " + texture;
|
||||||
return false;
|
return false;
|
||||||
|
@ -293,8 +294,7 @@ bool ResourcePack::Uninstall(const std::string& path)
|
||||||
// Recursively delete empty directories
|
// Recursively delete empty directories
|
||||||
|
|
||||||
std::string dir;
|
std::string dir;
|
||||||
|
SplitPath(texture_path, &dir, nullptr, nullptr);
|
||||||
SplitPath(path + TEXTURE_PATH + texture, &dir, nullptr, nullptr);
|
|
||||||
|
|
||||||
while (dir.length() > (path + TEXTURE_PATH).length())
|
while (dir.length() > (path + TEXTURE_PATH).length())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue