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:
parent
f272261c21
commit
c8c4105659
|
@ -21,14 +21,18 @@ 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) {
|
||||||
if (is_loaded) {
|
if (is_loaded) {
|
||||||
return ResultStatus::ErrorAlreadyLoaded;
|
return ResultStatus::ErrorAlreadyLoaded;
|
||||||
|
|
Loading…
Reference in New Issue