yuzu-emu
/
yuzu-mainline
Archived
1
0
Fork 0

submission_package: Invert conditionals within NSP's constructor to reduce nesting

We can use early continues here to reduce the amount of nesting.
This commit is contained in:
Lioncash 2018-10-03 01:11:12 -04:00
parent bc679c9b8c
commit 0d83f8f255
1 changed files with 49 additions and 45 deletions

View File

@ -45,7 +45,10 @@ NSP::NSP(VirtualFile file_)
Core::Crypto::KeyManager keys;
for (const auto& ticket_file : files) {
if (ticket_file->GetExtension() == "tik") {
if (ticket_file->GetExtension() != "tik") {
continue;
}
if (ticket_file == nullptr ||
ticket_file->GetSize() <
Core::Crypto::TICKET_FILE_TITLEKEY_OFFSET + sizeof(Core::Crypto::Key128)) {
@ -61,10 +64,12 @@ NSP::NSP(VirtualFile file_)
std::memcpy(rights_id.data(), rights_id_raw.data(), sizeof(u128));
keys.SetKey(Core::Crypto::S128KeyType::Titlekey, key, rights_id[1], rights_id[0]);
}
}
for (const auto& outer_file : files) {
if (outer_file->GetName().substr(outer_file->GetName().size() - 9) == ".cnmt.nca") {
if (outer_file->GetName().substr(outer_file->GetName().size() - 9) != ".cnmt.nca") {
continue;
}
const auto nca = std::make_shared<NCA>(outer_file);
if (nca->GetStatus() != Loader::ResultStatus::Success) {
program_status[nca->GetTitleId()] = nca->GetStatus();
@ -103,7 +108,6 @@ NSP::NSP(VirtualFile file_)
}
}
}
}
NSP::~NSP() = default;