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.
This commit is contained in:
Lioncash 2018-09-19 13:54:43 -04:00
parent f272261c21
commit c8c4105659
1 changed files with 8 additions and 4 deletions

View File

@ -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) {