Skip to content

Commit

Permalink
Pass YGFloatOptional by value, not reference
Browse files Browse the repository at this point in the history
Summary:
@public

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

Reviewed By: SidharthGuglani

Differential Revision: D13209150

fbshipit-source-id: c7b937a640258256c97e082ba2f832754e191b9a
  • Loading branch information
davidaurelio authored and facebook-github-bot committed Dec 6, 2018
1 parent 4157a49 commit a7757f6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions ReactCommon/yoga/yoga/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ float YGFloatSanitize(const float val) {
return yoga::isUndefined(val) ? 0 : val;
}

float YGUnwrapFloatOptional(const YGFloatOptional& op) {
float YGUnwrapFloatOptional(const YGFloatOptional op) {
return op.unwrap();
}

YGFloatOptional YGFloatOptionalMax(
const YGFloatOptional& op1,
const YGFloatOptional& op2) {
const YGFloatOptional op1,
const YGFloatOptional op2) {
if (op1 > op2) {
return op1;
}
Expand Down
6 changes: 3 additions & 3 deletions ReactCommon/yoga/yoga/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ bool YGFloatsEqual(const float a, const float b);
float YGFloatMax(const float a, const float b);

YGFloatOptional YGFloatOptionalMax(
const YGFloatOptional& op1,
const YGFloatOptional& op2);
const YGFloatOptional op1,
const YGFloatOptional op2);

float YGFloatMin(const float a, const float b);

Expand All @@ -85,7 +85,7 @@ float YGFloatSanitize(const float val);
// This function unwraps optional and returns YGUndefined if not defined or
// op.value otherwise
// TODO: Get rid off this function
float YGUnwrapFloatOptional(const YGFloatOptional& op);
float YGUnwrapFloatOptional(const YGFloatOptional op);

YGFlexDirection YGFlexDirectionCross(
const YGFlexDirection flexDirection,
Expand Down
6 changes: 3 additions & 3 deletions ReactCommon/yoga/yoga/YGNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void YGNode::setLayoutLastOwnerDirection(YGDirection direction) {
}

void YGNode::setLayoutComputedFlexBasis(
const YGFloatOptional& computedFlexBasis) {
const YGFloatOptional computedFlexBasis) {
layout_.computedFlexBasis = computedFlexBasis;
}

Expand Down Expand Up @@ -445,7 +445,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) && paddingEdgeStart >= YGFloatOptional{0.0f}) {
return paddingEdgeStart;
Expand All @@ -460,7 +460,7 @@ YGFloatOptional YGNode::getLeadingPadding(
YGFloatOptional YGNode::getTrailingPadding(
const YGFlexDirection axis,
const float widthSize) const {
const YGFloatOptional& paddingEdgeEnd =
const YGFloatOptional paddingEdgeEnd =
YGResolveValue(style_.padding[YGEdgeEnd], widthSize);
if (YGFlexDirectionIsRow(axis) && paddingEdgeEnd >= YGFloatOptional{0.0f}) {
return paddingEdgeEnd;
Expand Down
2 changes: 1 addition & 1 deletion ReactCommon/yoga/yoga/YGNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions ReactCommon/yoga/yoga/Yoga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1323,14 +1323,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(
Expand All @@ -1339,7 +1339,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(
Expand Down

0 comments on commit a7757f6

Please sign in to comment.