summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-05-28 07:05:35 -0400
committerLioncash <mathew1800@gmail.com>2019-05-28 07:27:35 -0400
commitab0892e5a59cd415e8e714d18a785d0047617d3a (patch)
tree6e37aa5833921de6ee19de62db6073dffee0de97 /Source/Core
parent27ecb93b327ae52847633e2f78b073f1115124ec (diff)
UICommon/GameFile: Deduplicate string paths where applicable
Rather than construct strings twice, we can just construct it once and reuse it. While we're at it, we can move variables closer to where they're actually used within DownloadDefaultCover()
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/UICommon/GameFile.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/Source/Core/UICommon/GameFile.cpp b/Source/Core/UICommon/GameFile.cpp
index dc758ffac6..328ba936d9 100644
--- a/Source/Core/UICommon/GameFile.cpp
+++ b/Source/Core/UICommon/GameFile.cpp
@@ -186,13 +186,13 @@ bool GameFile::CustomCoverChanged()
// This icon naming format is intended as an alternative to Homebrew Channel icons
// for those who don't want to have a Homebrew Channel style folder structure.
- bool success = File::Exists(path + name + ".cover.png") &&
- File::ReadFileToString(path + name + ".cover.png", contents);
+ const std::string cover_path = path + name + ".cover.png";
+ bool success = File::Exists(cover_path) && File::ReadFileToString(cover_path, contents);
if (!success)
{
- success =
- File::Exists(path + "cover.png") && File::ReadFileToString(path + "cover.png", contents);
+ const std::string alt_cover_path = path + "cover.png";
+ success = File::Exists(alt_cover_path) && File::ReadFileToString(alt_cover_path, contents);
}
if (success)
@@ -207,17 +207,13 @@ void GameFile::DownloadDefaultCover()
return;
const auto cover_path = File::GetUserPath(D_COVERCACHE_IDX) + DIR_SEP;
+ const auto png_path = cover_path + m_gametdb_id + ".png";
// If the cover has already been downloaded, abort
- if (File::Exists(cover_path + m_gametdb_id + ".png"))
+ if (File::Exists(png_path))
return;
- Common::HttpRequest request;
-
std::string region_code;
-
- auto user_lang = SConfig::GetInstance().GetCurrentLanguage(DiscIO::IsWii(GetPlatform()));
-
switch (m_region)
{
case DiscIO::Region::NTSC_J:
@@ -230,6 +226,8 @@ void GameFile::DownloadDefaultCover()
region_code = "KO";
break;
case DiscIO::Region::PAL:
+ {
+ const auto user_lang = SConfig::GetInstance().GetCurrentLanguage(DiscIO::IsWii(GetPlatform()));
switch (user_lang)
{
case DiscIO::Language::German:
@@ -253,18 +251,20 @@ void GameFile::DownloadDefaultCover()
break;
}
break;
+ }
case DiscIO::Region::Unknown:
region_code = "EN";
break;
}
+ Common::HttpRequest request;
auto response =
request.Get(StringFromFormat(COVER_URL, region_code.c_str(), m_gametdb_id.c_str()));
if (response)
{
File::WriteStringToFile(std::string(response.value().begin(), response.value().end()),
- cover_path + m_gametdb_id + ".png");
+ png_path);
}
}