diff options
author | Lioncash <mathew1800@gmail.com> | 2018-07-22 03:28:08 -0400 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2018-07-22 03:30:35 -0400 |
commit | 0797657bc02ca8f29d38206e56e3de80689c6350 (patch) | |
tree | 9c61a1ffea8a03b5a0ef0287672dee4d924d44e3 /src | |
parent | 258a5cee8429f4f4a3a7a0ead64d20269470392c (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index f47fd217de..ba827181ba 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -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()) + 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; } |