diff options
author | Adam Lesinski <adamlesinski@google.com> | 2016-10-19 12:18:14 -0700 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2016-10-19 12:18:14 -0700 |
commit | cacb28f2d60858106e2819cc7d95a65e8bda890b (patch) | |
tree | c8ac4af72b0a9599983567029e5680c40f9883a3 /tools/aapt2/DominatorTree.cpp | |
parent | 733f0bc08ea0c93d095016a791c2914658d0cdde (diff) |
Use Google3 style guide with .clang-format
Test: style change only, builds ok
Change-Id: I885180e24cb2e7b58cfb4967c3bcb40058ce4078
Diffstat (limited to 'tools/aapt2/DominatorTree.cpp')
-rw-r--r-- | tools/aapt2/DominatorTree.cpp | 102 |
1 files changed, 52 insertions, 50 deletions
diff --git a/tools/aapt2/DominatorTree.cpp b/tools/aapt2/DominatorTree.cpp index 29587a8b39a7..8f6f78327559 100644 --- a/tools/aapt2/DominatorTree.cpp +++ b/tools/aapt2/DominatorTree.cpp @@ -14,76 +14,78 @@ * limitations under the License. */ -#include "ConfigDescription.h" #include "DominatorTree.h" +#include "ConfigDescription.h" #include <algorithm> namespace aapt { DominatorTree::DominatorTree( - const std::vector<std::unique_ptr<ResourceConfigValue>>& configs) { - for (const auto& config : configs) { - mProductRoots[config->product].tryAddChild( - util::make_unique<Node>(config.get(), nullptr)); - } + const std::vector<std::unique_ptr<ResourceConfigValue>>& configs) { + for (const auto& config : configs) { + mProductRoots[config->product].tryAddChild( + util::make_unique<Node>(config.get(), nullptr)); + } } void DominatorTree::accept(Visitor* visitor) { - for (auto& entry : mProductRoots) { - visitor->visitTree(entry.first, &entry.second); - } + for (auto& entry : mProductRoots) { + visitor->visitTree(entry.first, &entry.second); + } } bool DominatorTree::Node::tryAddChild(std::unique_ptr<Node> newChild) { - assert(newChild->mValue && "cannot add a root or empty node as a child"); - if (mValue && !dominates(newChild.get())) { - // This is not the root and the child dominates us. - return false; - } - return addChild(std::move(newChild)); + assert(newChild->mValue && "cannot add a root or empty node as a child"); + if (mValue && !dominates(newChild.get())) { + // This is not the root and the child dominates us. + return false; + } + return addChild(std::move(newChild)); } bool DominatorTree::Node::addChild(std::unique_ptr<Node> newChild) { - bool hasDominatedChildren = false; - // Demote children dominated by the new config. - for (auto& child : mChildren) { - if (newChild->dominates(child.get())) { - child->mParent = newChild.get(); - newChild->mChildren.push_back(std::move(child)); - child = {}; - hasDominatedChildren = true; - } + bool hasDominatedChildren = false; + // Demote children dominated by the new config. + for (auto& child : mChildren) { + if (newChild->dominates(child.get())) { + child->mParent = newChild.get(); + newChild->mChildren.push_back(std::move(child)); + child = {}; + hasDominatedChildren = true; } - // Remove dominated children. - if (hasDominatedChildren) { - mChildren.erase(std::remove_if(mChildren.begin(), mChildren.end(), - [](const std::unique_ptr<Node>& child) -> bool { - return child == nullptr; - }), mChildren.end()); + } + // Remove dominated children. + if (hasDominatedChildren) { + mChildren.erase( + std::remove_if(mChildren.begin(), mChildren.end(), + [](const std::unique_ptr<Node>& child) -> bool { + return child == nullptr; + }), + mChildren.end()); + } + // Add the new config to a child if a child dominates the new config. + for (auto& child : mChildren) { + if (child->dominates(newChild.get())) { + child->addChild(std::move(newChild)); + return true; } - // Add the new config to a child if a child dominates the new config. - for (auto& child : mChildren) { - if (child->dominates(newChild.get())) { - child->addChild(std::move(newChild)); - return true; - } - } - // The new config is not dominated by a child, so add it here. - newChild->mParent = this; - mChildren.push_back(std::move(newChild)); - return true; + } + // The new config is not dominated by a child, so add it here. + newChild->mParent = this; + mChildren.push_back(std::move(newChild)); + return true; } bool DominatorTree::Node::dominates(const Node* other) const { - // Check root node dominations. - if (other->isRootNode()) { - return isRootNode(); - } else if (isRootNode()) { - return true; - } - // Neither node is a root node; compare the configurations. - return mValue->config.dominates(other->mValue->config); + // Check root node dominations. + if (other->isRootNode()) { + return isRootNode(); + } else if (isRootNode()) { + return true; + } + // Neither node is a root node; compare the configurations. + return mValue->config.dominates(other->mValue->config); } -} // namespace aapt +} // namespace aapt |