Pass `YGFloatOptional` by value, not reference

Summary:
@public

`YGFloatOptional` is a 32bit type now, and can be passed by value efficiently.

Reviewed By: SidharthGuglani

Differential Revision: D13439603

fbshipit-source-id: e12539ad5b3cccbd5bc27869866ca66c023b24a7
This commit is contained in:
David Aurelio 2018-12-13 07:09:30 -08:00 committed by Facebook Github Bot
parent ada4831580
commit 688b3195c3
3 changed files with 10 additions and 11 deletions

View File

@ -175,7 +175,7 @@ void YGNode::setLayoutLastOwnerDirection(YGDirection direction) {
}
void YGNode::setLayoutComputedFlexBasis(
const YGFloatOptional& computedFlexBasis) {
const YGFloatOptional computedFlexBasis) {
layout_.computedFlexBasis = computedFlexBasis;
}
@ -451,7 +451,7 @@ float YGNode::getTrailingBorder(const YGFlexDirection flexDirection) const {
YGFloatOptional YGNode::getLeadingPadding(
const YGFlexDirection axis,
const float widthSize) const {
const YGFloatOptional& paddingEdgeStart =
const YGFloatOptional paddingEdgeStart =
YGResolveValue(style_.padding[YGEdgeStart], widthSize);
if (YGFlexDirectionIsRow(axis) &&
style_.padding[YGEdgeStart].unit != YGUnitUndefined &&
@ -468,11 +468,10 @@ YGFloatOptional YGNode::getLeadingPadding(
YGFloatOptional YGNode::getTrailingPadding(
const YGFlexDirection axis,
const float widthSize) const {
if (YGFlexDirectionIsRow(axis) &&
style_.padding[YGEdgeEnd].unit != YGUnitUndefined &&
!YGResolveValue(style_.padding[YGEdgeEnd], widthSize).isUndefined() &&
YGResolveValue(style_.padding[YGEdgeEnd], widthSize).unwrap() >= 0.0f) {
return YGResolveValue(style_.padding[YGEdgeEnd], widthSize);
const YGFloatOptional paddingEdgeEnd =
YGResolveValue(style_.padding[YGEdgeEnd], widthSize);
if (YGFlexDirectionIsRow(axis) && paddingEdgeEnd >= YGFloatOptional{0.0f}) {
return paddingEdgeEnd;
}
YGFloatOptional resolvedValue = YGResolveValue(

View File

@ -235,7 +235,7 @@ struct YGNode {
void setDirty(bool isDirty);
void setLayoutLastOwnerDirection(YGDirection direction);
void setLayoutComputedFlexBasis(const YGFloatOptional& computedFlexBasis);
void setLayoutComputedFlexBasis(const YGFloatOptional computedFlexBasis);
void setLayoutComputedFlexBasisGeneration(
uint32_t computedFlexBasisGeneration);
void setLayoutMeasuredDimension(float measuredDimension, int index);

View File

@ -1325,14 +1325,14 @@ static void YGNodeComputeFlexBasisForChild(
child->getConfig(), YGExperimentalFeatureWebFlexBasis) &&
child->getLayout().computedFlexBasisGeneration !=
gCurrentGenerationCount)) {
const YGFloatOptional& paddingAndBorder = YGFloatOptional(
const YGFloatOptional paddingAndBorder = YGFloatOptional(
YGNodePaddingAndBorderForAxis(child, mainAxis, ownerWidth));
child->setLayoutComputedFlexBasis(
YGFloatOptionalMax(resolvedFlexBasis, paddingAndBorder));
}
} else if (isMainAxisRow && isRowStyleDimDefined) {
// The width is definite, so use that as the flex basis.
const YGFloatOptional& paddingAndBorder = YGFloatOptional(
const YGFloatOptional paddingAndBorder = YGFloatOptional(
YGNodePaddingAndBorderForAxis(child, YGFlexDirectionRow, ownerWidth));
child->setLayoutComputedFlexBasis(YGFloatOptionalMax(
@ -1341,7 +1341,7 @@ static void YGNodeComputeFlexBasisForChild(
paddingAndBorder));
} else if (!isMainAxisRow && isColumnStyleDimDefined) {
// The height is definite, so use that as the flex basis.
const YGFloatOptional& paddingAndBorder =
const YGFloatOptional paddingAndBorder =
YGFloatOptional(YGNodePaddingAndBorderForAxis(
child, YGFlexDirectionColumn, ownerWidth));
child->setLayoutComputedFlexBasis(YGFloatOptionalMax(