Skip to content

Commit

Permalink
YGNodeComputeFlexBasisForChildren: remove output param
Browse files Browse the repository at this point in the history
Summary:
@public

`YGNodeComputeFlexBasisForChildren` was using an output parameter (`float&`) that is always initialised to `0.0f`.
Here, we move the initialisation inside `YGNodeComputeFlexBasisForChildren`, and simply return the result.

Reviewed By: astreet

Differential Revision: D13167509

fbshipit-source-id: cbea20e2deb82ec75a1c158b16c94f4a3e5e4c99
  • Loading branch information
davidaurelio authored and facebook-github-bot committed Nov 22, 2018
1 parent c34ad17 commit 8f283b9
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions ReactCommon/yoga/yoga/Yoga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1911,7 +1911,7 @@ static float YGNodeCalculateAvailableInnerDim(
return availableInnerDim;
}

static void YGNodeComputeFlexBasisForChildren(
static float YGNodeComputeFlexBasisForChildren(
const YGNodeRef node,
const float availableInnerWidth,
const float availableInnerHeight,
Expand All @@ -1920,8 +1920,8 @@ static void YGNodeComputeFlexBasisForChildren(
YGDirection direction,
YGFlexDirection mainAxis,
const YGConfigRef config,
bool performLayout,
float& totalOuterFlexBasis) {
bool performLayout) {
float totalOuterFlexBasis = 0.0f;
YGNodeRef singleFlexChild = nullptr;
YGVector children = node->getChildren();
YGMeasureMode measureModeMainDim =
Expand Down Expand Up @@ -1991,6 +1991,8 @@ static void YGNodeComputeFlexBasisForChildren(
child->getLayout().computedFlexBasis +
child->getMarginForAxis(mainAxis, availableInnerWidth));
}

return totalOuterFlexBasis;
}

// This function assumes that all the children of node have their
Expand Down Expand Up @@ -2902,11 +2904,9 @@ static void YGNodelayoutImpl(
const float availableInnerCrossDim =
isMainAxisRow ? availableInnerHeight : availableInnerWidth;

float totalOuterFlexBasis = 0;

// STEP 3: DETERMINE FLEX BASIS FOR EACH ITEM

YGNodeComputeFlexBasisForChildren(
float totalOuterFlexBasis = YGNodeComputeFlexBasisForChildren(
node,
availableInnerWidth,
availableInnerHeight,
Expand All @@ -2915,8 +2915,7 @@ static void YGNodelayoutImpl(
direction,
mainAxis,
config,
performLayout,
totalOuterFlexBasis);
performLayout);

const bool flexBasisOverflows = measureModeMainDim == YGMeasureModeUndefined
? false
Expand Down

0 comments on commit 8f283b9

Please sign in to comment.