mirror of
https://github.com/yuzu-mirror/yuzu
synced 2024-12-01 03:59:08 +00:00
nax: Avoid re-parsing NAX data with GetFileType()
An instance of the NAX apploader already has an existing NAX instance in memory. Calling directly into IdentifyType() directly would re-parse the whole file again into yet another NAX instance, only to toss it away again. This gets rid of unnecessary/redundant file parsing and allocations.
This commit is contained in:
parent
c8c4105659
commit
45195a51a7
2 changed files with 19 additions and 13 deletions
|
@ -11,16 +11,8 @@
|
||||||
#include "core/loader/nca.h"
|
#include "core/loader/nca.h"
|
||||||
|
|
||||||
namespace Loader {
|
namespace Loader {
|
||||||
|
namespace {
|
||||||
AppLoader_NAX::AppLoader_NAX(FileSys::VirtualFile file)
|
FileType IdentifyTypeImpl(const FileSys::NAX& nax) {
|
||||||
: AppLoader(file), nax(std::make_unique<FileSys::NAX>(file)),
|
|
||||||
nca_loader(std::make_unique<AppLoader_NCA>(nax->GetDecrypted())) {}
|
|
||||||
|
|
||||||
AppLoader_NAX::~AppLoader_NAX() = default;
|
|
||||||
|
|
||||||
FileType AppLoader_NAX::IdentifyType(const FileSys::VirtualFile& file) {
|
|
||||||
FileSys::NAX nax(file);
|
|
||||||
|
|
||||||
if (nax.GetStatus() != ResultStatus::Success) {
|
if (nax.GetStatus() != ResultStatus::Success) {
|
||||||
return FileType::Error;
|
return FileType::Error;
|
||||||
}
|
}
|
||||||
|
@ -32,6 +24,22 @@ FileType AppLoader_NAX::IdentifyType(const FileSys::VirtualFile& file) {
|
||||||
|
|
||||||
return FileType::NAX;
|
return FileType::NAX;
|
||||||
}
|
}
|
||||||
|
} // Anonymous namespace
|
||||||
|
|
||||||
|
AppLoader_NAX::AppLoader_NAX(FileSys::VirtualFile file)
|
||||||
|
: AppLoader(file), nax(std::make_unique<FileSys::NAX>(file)),
|
||||||
|
nca_loader(std::make_unique<AppLoader_NCA>(nax->GetDecrypted())) {}
|
||||||
|
|
||||||
|
AppLoader_NAX::~AppLoader_NAX() = default;
|
||||||
|
|
||||||
|
FileType AppLoader_NAX::IdentifyType(const FileSys::VirtualFile& file) {
|
||||||
|
const FileSys::NAX nax(file);
|
||||||
|
return IdentifyTypeImpl(nax);
|
||||||
|
}
|
||||||
|
|
||||||
|
FileType AppLoader_NAX::GetFileType() {
|
||||||
|
return IdentifyTypeImpl(*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) {
|
||||||
|
|
|
@ -31,9 +31,7 @@ public:
|
||||||
*/
|
*/
|
||||||
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
||||||
|
|
||||||
FileType GetFileType() override {
|
FileType GetFileType() override;
|
||||||
return IdentifyType(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
ResultStatus Load(Kernel::SharedPtr<Kernel::Process>& process) override;
|
ResultStatus Load(Kernel::SharedPtr<Kernel::Process>& process) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue