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

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();
@ -102,7 +107,6 @@ NSP::NSP(VirtualFile file_)
break;
}
}
}
}
NSP::~NSP() = default;