diff --git a/ReactCommon/yoga/yoga/YGNode.cpp b/ReactCommon/yoga/yoga/YGNode.cpp index 70f0f46ab6106a..14c072fb1a120e 100644 --- a/ReactCommon/yoga/yoga/YGNode.cpp +++ b/ReactCommon/yoga/yoga/YGNode.cpp @@ -34,15 +34,11 @@ YGBaselineFunc YGNode::getBaseline() const { return baseline_; } -YGStyle YGNode::getStyle() const { +YGStyle& YGNode::getStyle() { return style_; } -YGLayout YGNode::getLayout() const { - return layout_; -} - -YGLayout& YGNode::getLayoutRef() { +YGLayout& YGNode::getLayout() { return layout_; } @@ -248,21 +244,21 @@ YGNode::YGNode() resolvedDimensions_({{YGValueUndefined, YGValueUndefined}}) {} YGNode::YGNode(const YGNode& node) - : context_(node.getContext()), - print_(node.getPrintFunc()), - hasNewLayout_(node.getHasNewLayout()), - nodeType_(node.getNodeType()), - measure_(node.getMeasure()), - baseline_(node.getBaseline()), - style_(node.getStyle()), - layout_(node.getLayout()), - lineIndex_(node.getLineIndex()), - parent_(node.getParent()), - children_(node.getChildren()), - nextChild_(node.getNextChild()), - config_(node.getConfig()), - isDirty_(node.isDirty()), - resolvedDimensions_(node.getResolvedDimensions()) {} + : context_(node.context_), + print_(node.print_), + hasNewLayout_(node.hasNewLayout_), + nodeType_(node.nodeType_), + measure_(node.measure_), + baseline_(node.baseline_), + style_(node.style_), + layout_(node.layout_), + lineIndex_(node.lineIndex_), + parent_(node.parent_), + children_(node.children_), + nextChild_(node.nextChild_), + config_(node.config_), + isDirty_(node.isDirty_), + resolvedDimensions_(node.resolvedDimensions_) {} YGNode::YGNode(const YGConfigRef newConfig) : YGNode() { config_ = newConfig; @@ -315,8 +311,8 @@ YGNode& YGNode::operator=(const YGNode& node) { nodeType_ = node.getNodeType(); measure_ = node.getMeasure(); baseline_ = node.getBaseline(); - style_ = node.getStyle(); - layout_ = node.getLayout(); + style_ = node.style_; + layout_ = node.layout_; lineIndex_ = node.getLineIndex(); parent_ = node.getParent(); children_ = node.getChildren(); @@ -330,28 +326,28 @@ YGNode& YGNode::operator=(const YGNode& node) { YGValue YGNode::marginLeadingValue(const YGFlexDirection axis) const { if (YGFlexDirectionIsRow(axis) && - getStyle().margin[YGEdgeStart].unit != YGUnitUndefined) { - return getStyle().margin[YGEdgeStart]; + style_.margin[YGEdgeStart].unit != YGUnitUndefined) { + return style_.margin[YGEdgeStart]; } else { - return getStyle().margin[leading[axis]]; + return style_.margin[leading[axis]]; } } YGValue YGNode::marginTrailingValue(const YGFlexDirection axis) const { if (YGFlexDirectionIsRow(axis) && - getStyle().margin[YGEdgeEnd].unit != YGUnitUndefined) { - return getStyle().margin[YGEdgeEnd]; + style_.margin[YGEdgeEnd].unit != YGUnitUndefined) { + return style_.margin[YGEdgeEnd]; } else { - return getStyle().margin[trailing[axis]]; + return style_.margin[trailing[axis]]; } } YGValue YGNode::resolveFlexBasisPtr() const { - YGValue flexBasis = getStyle().flexBasis; + YGValue flexBasis = style_.flexBasis; if (flexBasis.unit != YGUnitAuto && flexBasis.unit != YGUnitUndefined) { return flexBasis; } - if (!YGFloatIsUndefined(getStyle().flex) && getStyle().flex > 0.0f) { + if (!YGFloatIsUndefined(style_.flex) && style_.flex > 0.0f) { return config_->useWebDefaults ? YGValueAuto : YGValueZero; } return YGValueAuto; @@ -361,10 +357,10 @@ void YGNode::resolveDimension() { for (uint32_t dim = YGDimensionWidth; dim < YGDimensionCount; dim++) { if (getStyle().maxDimensions[dim].unit != YGUnitUndefined && YGValueEqual( - getStyle().maxDimensions[dim], getStyle().minDimensions[dim])) { - resolvedDimensions_[dim] = getStyle().maxDimensions[dim]; + getStyle().maxDimensions[dim], style_.minDimensions[dim])) { + resolvedDimensions_[dim] = style_.maxDimensions[dim]; } else { - resolvedDimensions_[dim] = getStyle().dimensions[dim]; + resolvedDimensions_[dim] = style_.dimensions[dim]; } } } diff --git a/ReactCommon/yoga/yoga/YGNode.h b/ReactCommon/yoga/yoga/YGNode.h index a5062bdb850211..4e76b35b2924ac 100644 --- a/ReactCommon/yoga/yoga/YGNode.h +++ b/ReactCommon/yoga/yoga/YGNode.h @@ -60,9 +60,10 @@ struct YGNode { YGNodeType getNodeType() const; YGMeasureFunc getMeasure() const; YGBaselineFunc getBaseline() const; - YGStyle getStyle() const; - YGLayout getLayout() const; - YGLayout& getLayoutRef(); // TODO remove its use + // For Perfomance reasons passing as reference. + YGStyle& getStyle(); + // For Perfomance reasons passing as reference. + YGLayout& getLayout(); uint32_t getLineIndex() const; YGNodeRef getParent() const; YGVector getChildren() const; diff --git a/ReactCommon/yoga/yoga/Yoga.cpp b/ReactCommon/yoga/yoga/Yoga.cpp index 188354db85a988..6f6b2f6f0d7a2d 100644 --- a/ReactCommon/yoga/yoga/Yoga.cpp +++ b/ReactCommon/yoga/yoga/Yoga.cpp @@ -1803,7 +1803,7 @@ static bool YGNodeFixedSizeSetMeasuredDimensions(const YGNodeRef node, } static void YGZeroOutLayoutRecursivly(const YGNodeRef node) { - memset(&(node->getLayoutRef()), 0, sizeof(YGLayout)); + memset(&(node->getLayout()), 0, sizeof(YGLayout)); node->setHasNewLayout(true); YGCloneChildrenIfNeeded(node); const uint32_t childCount = YGNodeGetChildCount(node); @@ -3341,7 +3341,7 @@ bool YGLayoutNodeInternal(const YGNodeRef node, const bool performLayout, const char *reason, const YGConfigRef config) { - YGLayout* layout = &node->getLayoutRef(); + YGLayout* layout = &node->getLayout(); gDepth++;