From 8eb1398f8d90fb2813f438b9fffac716b6ec51d2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 5 Oct 2019 08:17:32 -0400 Subject: video_core/{ast, expr}: Use std::move where applicable Avoids unnecessary atomic reference count increments and decrements. --- src/video_core/shader/ast.h | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src/video_core/shader/ast.h') diff --git a/src/video_core/shader/ast.h b/src/video_core/shader/ast.h index 39f500284..aad35c12e 100644 --- a/src/video_core/shader/ast.h +++ b/src/video_core/shader/ast.h @@ -71,20 +71,18 @@ public: class ASTProgram { public: - explicit ASTProgram() = default; ASTZipper nodes{}; }; class ASTIfThen { public: - explicit ASTIfThen(Expr condition) : condition(condition) {} + explicit ASTIfThen(Expr condition) : condition{std::move(condition)} {} Expr condition; ASTZipper nodes{}; }; class ASTIfElse { public: - explicit ASTIfElse() = default; ASTZipper nodes{}; }; @@ -103,7 +101,7 @@ public: class ASTVarSet { public: - explicit ASTVarSet(u32 index, Expr condition) : index{index}, condition{condition} {} + explicit ASTVarSet(u32 index, Expr condition) : index{index}, condition{std::move(condition)} {} u32 index; Expr condition; }; @@ -117,42 +115,45 @@ public: class ASTGoto { public: - explicit ASTGoto(Expr condition, u32 label) : condition{condition}, label{label} {} + explicit ASTGoto(Expr condition, u32 label) : condition{std::move(condition)}, label{label} {} Expr condition; u32 label; }; class ASTDoWhile { public: - explicit ASTDoWhile(Expr condition) : condition(condition) {} + explicit ASTDoWhile(Expr condition) : condition{std::move(condition)} {} Expr condition; ASTZipper nodes{}; }; class ASTReturn { public: - explicit ASTReturn(Expr condition, bool kills) : condition{condition}, kills{kills} {} + explicit ASTReturn(Expr condition, bool kills) + : condition{std::move(condition)}, kills{kills} {} Expr condition; bool kills; }; class ASTBreak { public: - explicit ASTBreak(Expr condition) : condition{condition} {} + explicit ASTBreak(Expr condition) : condition{std::move(condition)} {} Expr condition; }; class ASTBase { public: - explicit ASTBase(ASTNode parent, ASTData data) : parent{parent}, data{data} {} + explicit ASTBase(ASTNode parent, ASTData data) + : data{std::move(data)}, parent{std::move(parent)} {} template static ASTNode Make(ASTNode parent, Args&&... args) { - return std::make_shared(parent, ASTData(U(std::forward(args)...))); + return std::make_shared(std::move(parent), + ASTData(U(std::forward(args)...))); } void SetParent(ASTNode new_parent) { - parent = new_parent; + parent = std::move(new_parent); } ASTNode& GetParent() { @@ -247,7 +248,7 @@ public: void SetGotoCondition(Expr new_condition) { auto inner = std::get_if(&data); if (inner) { - inner->condition = new_condition; + inner->condition = std::move(new_condition); } } @@ -370,9 +371,9 @@ public: private: bool IsBackwardsJump(ASTNode goto_node, ASTNode label_node) const; - bool IndirectlyRelated(ASTNode first, ASTNode second); + bool IndirectlyRelated(const ASTNode& first, const ASTNode& second) const; - bool DirectlyRelated(ASTNode first, ASTNode second); + bool DirectlyRelated(const ASTNode& first, const ASTNode& second) const; void EncloseDoWhile(ASTNode goto_node, ASTNode label); -- cgit v1.2.3