diff options
author | Lioncash <mathew1800@gmail.com> | 2019-10-05 08:17:32 -0400 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2019-10-05 09:14:23 -0400 |
commit | 8eb1398f8d90fb2813f438b9fffac716b6ec51d2 (patch) | |
tree | 39a270023b64af2dce85e3d4a13484c95243b2b3 /src/video_core/shader/ast.cpp | |
parent | 8e0c80f26914552e11144bd92dae726b66c3739d (diff) |
video_core/{ast, expr}: Use std::move where applicable
Avoids unnecessary atomic reference count increments and decrements.
Diffstat (limited to 'src/video_core/shader/ast.cpp')
-rw-r--r-- | src/video_core/shader/ast.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/video_core/shader/ast.cpp b/src/video_core/shader/ast.cpp index 87c7226821..986e4cd64b 100644 --- a/src/video_core/shader/ast.cpp +++ b/src/video_core/shader/ast.cpp @@ -17,6 +17,7 @@ void ASTZipper::Init(const ASTNode new_first, const ASTNode parent) { ASSERT(new_first->manager == nullptr); first = new_first; last = new_first; + ASTNode current = first; while (current) { current->manager = this; @@ -92,7 +93,7 @@ void ASTZipper::InsertBefore(const ASTNode new_node, const ASTNode at_node) { new_node->manager = this; } -void ASTZipper::DetachTail(const ASTNode node) { +void ASTZipper::DetachTail(ASTNode node) { ASSERT(node->manager == this); if (node == first) { first.reset(); @@ -103,7 +104,8 @@ void ASTZipper::DetachTail(const ASTNode node) { last = node->previous; last->next.reset(); node->previous.reset(); - ASTNode current = node; + + ASTNode current = std::move(node); while (current) { current->manager = nullptr; current->parent.reset(); @@ -413,19 +415,19 @@ void ASTManager::InsertLabel(u32 address) { void ASTManager::InsertGoto(Expr condition, u32 address) { const u32 index = labels_map[address]; - const ASTNode goto_node = ASTBase::Make<ASTGoto>(main_node, condition, index); + const ASTNode goto_node = ASTBase::Make<ASTGoto>(main_node, std::move(condition), index); gotos.push_back(goto_node); program->nodes.PushBack(goto_node); } void ASTManager::InsertBlock(u32 start_address, u32 end_address) { - const ASTNode block = ASTBase::Make<ASTBlockEncoded>(main_node, start_address, end_address); - program->nodes.PushBack(block); + ASTNode block = ASTBase::Make<ASTBlockEncoded>(main_node, start_address, end_address); + program->nodes.PushBack(std::move(block)); } void ASTManager::InsertReturn(Expr condition, bool kills) { - const ASTNode node = ASTBase::Make<ASTReturn>(main_node, condition, kills); - program->nodes.PushBack(node); + ASTNode node = ASTBase::Make<ASTReturn>(main_node, std::move(condition), kills); + program->nodes.PushBack(std::move(node)); } // The decompile algorithm is based on @@ -539,11 +541,11 @@ bool ASTManager::IsBackwardsJump(ASTNode goto_node, ASTNode label_node) const { return false; } -bool ASTManager::IndirectlyRelated(ASTNode first, ASTNode second) { +bool ASTManager::IndirectlyRelated(const ASTNode& first, const ASTNode& second) const { return !(first->GetParent() == second->GetParent() || DirectlyRelated(first, second)); } -bool ASTManager::DirectlyRelated(ASTNode first, ASTNode second) { +bool ASTManager::DirectlyRelated(const ASTNode& first, const ASTNode& second) const { if (first->GetParent() == second->GetParent()) { return false; } |