summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2018-09-19 13:54:43 -0400
committerGravatar Lioncash2018-09-19 14:22:37 -0400
commitc8c410565927b54b2a1353ca00a1c4de38a74816 (patch)
treee1f1415a031776d6f8b779be1464882d977a1312 /src
parentxts_archive: Ensure NAX's type member is always initialized (diff)
downloadyuzu-c8c410565927b54b2a1353ca00a1c4de38a74816.tar.gz
yuzu-c8c410565927b54b2a1353ca00a1c4de38a74816.tar.xz
yuzu-c8c410565927b54b2a1353ca00a1c4de38a74816.zip
nax: Avoid unnecessary calls to AsNCA() in IdentifyType()
AsNCA() allocates an NCA instance every time it's called. In the current manner it's used, it's quite inefficient as it's making a redundant allocation. We can just amend the order of the conditionals to make it easier to just call it once.
Diffstat (limited to 'src')
-rw-r--r--src/core/loader/nax.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/core/loader/nax.cpp b/src/core/loader/nax.cpp
index b46d81c02..02a0d5ba7 100644
--- a/src/core/loader/nax.cpp
+++ b/src/core/loader/nax.cpp
@@ -21,12 +21,16 @@ AppLoader_NAX::~AppLoader_NAX() = default;
21FileType AppLoader_NAX::IdentifyType(const FileSys::VirtualFile& file) { 21FileType AppLoader_NAX::IdentifyType(const FileSys::VirtualFile& file) {
22 FileSys::NAX nax(file); 22 FileSys::NAX nax(file);
23 23
24 if (nax.GetStatus() == ResultStatus::Success && nax.AsNCA() != nullptr && 24 if (nax.GetStatus() != ResultStatus::Success) {
25 nax.AsNCA()->GetStatus() == ResultStatus::Success) { 25 return FileType::Error;
26 return FileType::NAX;
27 } 26 }
28 27
29 return FileType::Error; 28 const auto nca = nax.AsNCA();
29 if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) {
30 return FileType::Error;
31 }
32
33 return FileType::NAX;
30} 34}
31 35
32ResultStatus AppLoader_NAX::Load(Kernel::SharedPtr<Kernel::Process>& process) { 36ResultStatus AppLoader_NAX::Load(Kernel::SharedPtr<Kernel::Process>& process) {