1
1
Fork 0
forked from suyu/suyu

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

View file

@ -21,12 +21,16 @@ AppLoader_NAX::~AppLoader_NAX() = default;
FileType AppLoader_NAX::IdentifyType(const FileSys::VirtualFile& file) { FileType AppLoader_NAX::IdentifyType(const FileSys::VirtualFile& file) {
FileSys::NAX nax(file); FileSys::NAX nax(file);
if (nax.GetStatus() == ResultStatus::Success && nax.AsNCA() != nullptr && if (nax.GetStatus() != ResultStatus::Success) {
nax.AsNCA()->GetStatus() == ResultStatus::Success) { return FileType::Error;
return FileType::NAX;
} }
const auto nca = nax.AsNCA();
if (nca == nullptr || nca->GetStatus() != ResultStatus::Success) {
return FileType::Error; return FileType::Error;
}
return FileType::NAX;
} }
ResultStatus AppLoader_NAX::Load(Kernel::SharedPtr<Kernel::Process>& process) { ResultStatus AppLoader_NAX::Load(Kernel::SharedPtr<Kernel::Process>& process) {