aboutsummaryrefslogtreecommitdiff
path: root/src/core/loader/nax.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2018-09-19 13:54:43 -0400
committerLioncash <mathew1800@gmail.com>2018-09-19 14:22:37 -0400
commit20ebe330713e3ff6209d57de9c2565022f14cf62 (patch)
treee1f1415a031776d6f8b779be1464882d977a1312 /src/core/loader/nax.cpp
parenta832a42fe02edca74f00143f06e682a124de5034 (diff)
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/core/loader/nax.cpp')
-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 b46d81c022..02a0d5ba74 100644
--- a/src/core/loader/nax.cpp
+++ b/src/core/loader/nax.cpp
@@ -21,12 +21,16 @@ AppLoader_NAX::~AppLoader_NAX() = default;
FileType AppLoader_NAX::IdentifyType(const FileSys::VirtualFile& file) {
FileSys::NAX nax(file);
- if (nax.GetStatus() == ResultStatus::Success && nax.AsNCA() != nullptr &&
- nax.AsNCA()->GetStatus() == ResultStatus::Success) {
- return FileType::NAX;
+ if (nax.GetStatus() != ResultStatus::Success) {
+ return FileType::Error;
}
- return FileType::Error;
+ const auto nca = nax.AsNCA();
+ if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) {
+ return FileType::Error;
+ }
+
+ return FileType::NAX;
}
ResultStatus AppLoader_NAX::Load(Kernel::SharedPtr<Kernel::Process>& process) {