diff --git a/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.cpp b/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.cpp index 5941baa05..69ed31115 100644 --- a/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.cpp +++ b/ReactCommon/fabric/view/yoga/YogaLayoutableShadowNode.cpp @@ -94,7 +94,7 @@ void YogaLayoutableShadowNode::appendChild(SharedYogaLayoutableShadowNode child) auto yogaNodeRawPtr = &yogaNode_; auto childYogaNodeRawPtr = &child->yogaNode_; - yogaNodeRawPtr->insertChild(childYogaNodeRawPtr, yogaNodeRawPtr->getChildrenCount()); + yogaNodeRawPtr->insertChild(childYogaNodeRawPtr, yogaNodeRawPtr->getChildren().size()); if (childYogaNodeRawPtr->getOwner() == nullptr) { child->ensureUnsealed(); diff --git a/ReactCommon/yoga/yoga/YGNode.h b/ReactCommon/yoga/yoga/YGNode.h index ab302e067..c204d4600 100644 --- a/ReactCommon/yoga/yoga/YGNode.h +++ b/ReactCommon/yoga/yoga/YGNode.h @@ -122,14 +122,10 @@ struct YGNode { return getOwner(); } - YGVector getChildren() const { + const YGVector& getChildren() const { return children_; } - uint32_t getChildrenCount() const { - return static_cast(children_.size()); - } - YGNodeRef getChild(uint32_t index) const { return children_.at(index); } diff --git a/ReactCommon/yoga/yoga/Yoga.cpp b/ReactCommon/yoga/yoga/Yoga.cpp index 5b5a90888..df186c7c3 100644 --- a/ReactCommon/yoga/yoga/Yoga.cpp +++ b/ReactCommon/yoga/yoga/Yoga.cpp @@ -264,7 +264,7 @@ static YGNodeRef YGNodeDeepClone(YGNodeRef oldNode) { YGVector vec = YGVector(); vec.reserve(oldNode->getChildren().size()); YGNodeRef childNode = nullptr; - for (auto& item : oldNode->getChildren()) { + for (auto* item : oldNode->getChildren()) { childNode = YGNodeDeepClone(item); childNode->setOwner(node); vec.push_back(childNode); @@ -301,8 +301,8 @@ static void YGConfigFreeRecursive(const YGNodeRef root) { delete root->getConfig(); } // Delete configs recursively for childrens - for (uint32_t i = 0; i < root->getChildrenCount(); ++i) { - YGConfigFreeRecursive(root->getChild(i)); + for (auto* child : root->getChildren()) { + YGConfigFreeRecursive(child); } } @@ -1868,7 +1868,7 @@ static YGCollectFlexItemsRowValues YGCalculateCollectFlexItemsRowValues( // Add items to the current line until it's full or we run out of items. uint32_t endOfLineIndex = startOfLineIndex; - for (; endOfLineIndex < node->getChildrenCount(); endOfLineIndex++) { + for (; endOfLineIndex < node->getChildren().size(); endOfLineIndex++) { const YGNodeRef child = node->getChild(endOfLineIndex); if (child->getStyle().display == YGDisplayNone || child->getStyle().positionType == YGPositionTypeAbsolute) {