yuzu-emu
/
yuzu
Archived
1
0
Fork 0

gl_shader_decompiler: Remove redundant Subroutine construction in AddSubroutine()

We don't need to toss away the Subroutine instance after the find() call
and reconstruct another instance with the same data right after it.
Particularly give Subroutine contains a std::set.
This commit is contained in:
Lioncash 2018-07-22 03:28:08 -04:00
parent 258a5cee84
commit 0797657bc0
1 changed files with 9 additions and 5 deletions

View File

@ -78,14 +78,18 @@ private:
/// Adds and analyzes a new subroutine if it is not added yet.
const Subroutine& AddSubroutine(u32 begin, u32 end, const std::string& suffix) {
auto iter = subroutines.find(Subroutine{begin, end, suffix});
if (iter != subroutines.end())
return *iter;
Subroutine subroutine{begin, end, suffix, ExitMethod::Undetermined, {}};
const auto iter = subroutines.find(subroutine);
if (iter != subroutines.end()) {
return *iter;
}
Subroutine subroutine{begin, end, suffix};
subroutine.exit_method = Scan(begin, end, subroutine.labels);
if (subroutine.exit_method == ExitMethod::Undetermined)
if (subroutine.exit_method == ExitMethod::Undetermined) {
throw DecompileFail("Recursive function detected");
}
return *subroutines.insert(std::move(subroutine)).first;
}