From f871bbada25b0ff30a7963860c58cbf14973f6cf Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 20 Dec 2019 01:00:07 -0800 Subject: [PATCH] Cosmetic adjustments to ShadowNode::getAncestors Summary: Changelog: [internal] Just cosmetic changes to code, shouldn't affect behaviour at all. Reviewed By: shergin Differential Revision: D19177494 fbshipit-source-id: b2e4d3d2cf0d30f40f2e2d950dd7a10dc7a5b5ea --- ReactCommon/fabric/core/shadownode/ShadowNode.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ReactCommon/fabric/core/shadownode/ShadowNode.cpp b/ReactCommon/fabric/core/shadownode/ShadowNode.cpp index 68dce5fc539..1178933848f 100644 --- a/ReactCommon/fabric/core/shadownode/ShadowNode.cpp +++ b/ReactCommon/fabric/core/shadownode/ShadowNode.cpp @@ -229,27 +229,25 @@ void ShadowNode::setMounted(bool mounted) const { AncestorList ShadowNode::getAncestors( ShadowNode const &ancestorShadowNode) const { - auto ancestors = AncestorList{}; auto families = better::small_vector{}; auto ancestorFamily = ancestorShadowNode.family_.get(); - auto descendantFamily = family_.get(); - auto family = descendantFamily; + auto family = family_.get(); while (family && family != ancestorFamily) { families.push_back(family); family = family->parent_.lock().get(); } if (family != ancestorFamily) { - ancestors.clear(); - return ancestors; + return {}; } + auto ancestors = AncestorList{}; auto parentNode = &ancestorShadowNode; for (auto it = families.rbegin(); it != families.rend(); it++) { auto childFamily = *it; - auto found = bool{false}; - auto childIndex = int{0}; + auto found = false; + auto childIndex = 0; for (const auto &childNode : *parentNode->children_) { if (childNode->family_.get() == childFamily) { ancestors.push_back({*parentNode, childIndex});