YGNode::getChildren() should return const ref
Summary:
It's wasteful to do it by value. I'm fairly sure this is
safe, especially because
fbd332dee8 (diff-ade2a4bbd6582e2898cbd9e0fa142ab5R215)
shows that we did access by reference before.
Reviewed By: priteshrnandgaonkar, davidaurelio
Differential Revision: D8822697
fbshipit-source-id: 791bcf0fa37453f67795af727c85c8adce3b0f69
This commit is contained in:
committed by
Facebook Github Bot
parent
e9e2ae28e0
commit
0b1780a081
@@ -122,14 +122,10 @@ struct YGNode {
|
||||
return getOwner();
|
||||
}
|
||||
|
||||
YGVector getChildren() const {
|
||||
const YGVector& getChildren() const {
|
||||
return children_;
|
||||
}
|
||||
|
||||
uint32_t getChildrenCount() const {
|
||||
return static_cast<uint32_t>(children_.size());
|
||||
}
|
||||
|
||||
YGNodeRef getChild(uint32_t index) const {
|
||||
return children_.at(index);
|
||||
}
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user