mirror of
https://github.com/status-im/react-native.git
synced 2025-02-26 16:10:58 +00:00
Optimize the performance of Origami
Reviewed By: emilsjolander Differential Revision: D6619293 fbshipit-source-id: c1632efd97f47696b7f8bb1b3e763de92c707287
This commit is contained in:
parent
3559e42c55
commit
a163f70f87
@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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++;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user