diff options
| author | 2019-10-05 08:17:32 -0400 | |
|---|---|---|
| committer | 2019-10-05 09:14:23 -0400 | |
| commit | 8eb1398f8d90fb2813f438b9fffac716b6ec51d2 (patch) | |
| tree | 39a270023b64af2dce85e3d4a13484c95243b2b3 /src/video_core/shader/ast.cpp | |
| parent | video_core/ast: Supply const accessors for data where applicable (diff) | |
| download | yuzu-8eb1398f8d90fb2813f438b9fffac716b6ec51d2.tar.gz yuzu-8eb1398f8d90fb2813f438b9fffac716b6ec51d2.tar.xz yuzu-8eb1398f8d90fb2813f438b9fffac716b6ec51d2.zip | |
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 87c722682..986e4cd64 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) { | |||
| 17 | ASSERT(new_first->manager == nullptr); | 17 | ASSERT(new_first->manager == nullptr); |
| 18 | first = new_first; | 18 | first = new_first; |
| 19 | last = new_first; | 19 | last = new_first; |
| 20 | |||
| 20 | ASTNode current = first; | 21 | ASTNode current = first; |
| 21 | while (current) { | 22 | while (current) { |
| 22 | current->manager = this; | 23 | current->manager = this; |
| @@ -92,7 +93,7 @@ void ASTZipper::InsertBefore(const ASTNode new_node, const ASTNode at_node) { | |||
| 92 | new_node->manager = this; | 93 | new_node->manager = this; |
| 93 | } | 94 | } |
| 94 | 95 | ||
| 95 | void ASTZipper::DetachTail(const ASTNode node) { | 96 | void ASTZipper::DetachTail(ASTNode node) { |
| 96 | ASSERT(node->manager == this); | 97 | ASSERT(node->manager == this); |
| 97 | if (node == first) { | 98 | if (node == first) { |
| 98 | first.reset(); | 99 | first.reset(); |
| @@ -103,7 +104,8 @@ void ASTZipper::DetachTail(const ASTNode node) { | |||
| 103 | last = node->previous; | 104 | last = node->previous; |
| 104 | last->next.reset(); | 105 | last->next.reset(); |
| 105 | node->previous.reset(); | 106 | node->previous.reset(); |
| 106 | ASTNode current = node; | 107 | |
| 108 | ASTNode current = std::move(node); | ||
| 107 | while (current) { | 109 | while (current) { |
| 108 | current->manager = nullptr; | 110 | current->manager = nullptr; |
| 109 | current->parent.reset(); | 111 | current->parent.reset(); |
| @@ -413,19 +415,19 @@ void ASTManager::InsertLabel(u32 address) { | |||
| 413 | 415 | ||
| 414 | void ASTManager::InsertGoto(Expr condition, u32 address) { | 416 | void ASTManager::InsertGoto(Expr condition, u32 address) { |
| 415 | const u32 index = labels_map[address]; | 417 | const u32 index = labels_map[address]; |
| 416 | const ASTNode goto_node = ASTBase::Make<ASTGoto>(main_node, condition, index); | 418 | const ASTNode goto_node = ASTBase::Make<ASTGoto>(main_node, std::move(condition), index); |
| 417 | gotos.push_back(goto_node); | 419 | gotos.push_back(goto_node); |
| 418 | program->nodes.PushBack(goto_node); | 420 | program->nodes.PushBack(goto_node); |
| 419 | } | 421 | } |
| 420 | 422 | ||
| 421 | void ASTManager::InsertBlock(u32 start_address, u32 end_address) { | 423 | void ASTManager::InsertBlock(u32 start_address, u32 end_address) { |
| 422 | const ASTNode block = ASTBase::Make<ASTBlockEncoded>(main_node, start_address, end_address); | 424 | ASTNode block = ASTBase::Make<ASTBlockEncoded>(main_node, start_address, end_address); |
| 423 | program->nodes.PushBack(block); | 425 | program->nodes.PushBack(std::move(block)); |
| 424 | } | 426 | } |
| 425 | 427 | ||
| 426 | void ASTManager::InsertReturn(Expr condition, bool kills) { | 428 | void ASTManager::InsertReturn(Expr condition, bool kills) { |
| 427 | const ASTNode node = ASTBase::Make<ASTReturn>(main_node, condition, kills); | 429 | ASTNode node = ASTBase::Make<ASTReturn>(main_node, std::move(condition), kills); |
| 428 | program->nodes.PushBack(node); | 430 | program->nodes.PushBack(std::move(node)); |
| 429 | } | 431 | } |
| 430 | 432 | ||
| 431 | // The decompile algorithm is based on | 433 | // The decompile algorithm is based on |
| @@ -539,11 +541,11 @@ bool ASTManager::IsBackwardsJump(ASTNode goto_node, ASTNode label_node) const { | |||
| 539 | return false; | 541 | return false; |
| 540 | } | 542 | } |
| 541 | 543 | ||
| 542 | bool ASTManager::IndirectlyRelated(ASTNode first, ASTNode second) { | 544 | bool ASTManager::IndirectlyRelated(const ASTNode& first, const ASTNode& second) const { |
| 543 | return !(first->GetParent() == second->GetParent() || DirectlyRelated(first, second)); | 545 | return !(first->GetParent() == second->GetParent() || DirectlyRelated(first, second)); |
| 544 | } | 546 | } |
| 545 | 547 | ||
| 546 | bool ASTManager::DirectlyRelated(ASTNode first, ASTNode second) { | 548 | bool ASTManager::DirectlyRelated(const ASTNode& first, const ASTNode& second) const { |
| 547 | if (first->GetParent() == second->GetParent()) { | 549 | if (first->GetParent() == second->GetParent()) { |
| 548 | return false; | 550 | return false; |
| 549 | } | 551 | } |