summaryrefslogtreecommitdiff
path: root/src/video_core
diff options
context:
space:
mode:
authorGravatar Lioncash2019-05-22 17:35:58 -0400
committerGravatar Rodrigo Locatti2019-05-23 03:01:55 -0300
commitb6dcb1ae4d95b8fe83357709526ed07c9b923652 (patch)
treec1f9c5abe823f0653d5a48fdffbc7993d28d3893 /src/video_core
parentshader/decode/*: Add missing newline to files lacking them (diff)
downloadyuzu-b6dcb1ae4d95b8fe83357709526ed07c9b923652.tar.gz
yuzu-b6dcb1ae4d95b8fe83357709526ed07c9b923652.tar.xz
yuzu-b6dcb1ae4d95b8fe83357709526ed07c9b923652.zip
shader/shader_ir: Make Comment() take a std::string by value
This allows for forming comment nodes without making unnecessary copies of the std::string instance. e.g. previously: Comment(fmt::format("Base address is c[0x{:x}][0x{:x}]", cbuf->GetIndex(), cbuf_offset)); Would result in a copy of the string being created, as CommentNode() takes a std::string by value (a const ref passed to a value parameter results in a copy). Now, only one instance of the string is ever moved around. (fmt::format returns a std::string, and since it's returned from a function by value, this is a prvalue (which can be treated like an rvalue), so it's moved into Comment's string parameter), we then move it into the CommentNode constructor, which then moves the string into its member variable).
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/shader/shader_ir.cpp4
-rw-r--r--src/video_core/shader/shader_ir.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/video_core/shader/shader_ir.cpp b/src/video_core/shader/shader_ir.cpp
index 153ad1fd0..8a6ee5cf5 100644
--- a/src/video_core/shader/shader_ir.cpp
+++ b/src/video_core/shader/shader_ir.cpp
@@ -39,8 +39,8 @@ Node ShaderIR::Conditional(Node condition, std::vector<Node>&& code) {
39 return StoreNode(ConditionalNode(condition, std::move(code))); 39 return StoreNode(ConditionalNode(condition, std::move(code)));
40} 40}
41 41
42Node ShaderIR::Comment(const std::string& text) { 42Node ShaderIR::Comment(std::string text) {
43 return StoreNode(CommentNode(text)); 43 return StoreNode(CommentNode(std::move(text)));
44} 44}
45 45
46Node ShaderIR::Immediate(u32 value) { 46Node ShaderIR::Immediate(u32 value) {
diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h
index 0bf124252..34d183ec7 100644
--- a/src/video_core/shader/shader_ir.h
+++ b/src/video_core/shader/shader_ir.h
@@ -663,7 +663,7 @@ private:
663 /// Creates a conditional node 663 /// Creates a conditional node
664 Node Conditional(Node condition, std::vector<Node>&& code); 664 Node Conditional(Node condition, std::vector<Node>&& code);
665 /// Creates a commentary 665 /// Creates a commentary
666 Node Comment(const std::string& text); 666 Node Comment(std::string text);
667 /// Creates an u32 immediate 667 /// Creates an u32 immediate
668 Node Immediate(u32 value); 668 Node Immediate(u32 value);
669 /// Creates a s32 immediate 669 /// Creates a s32 immediate