Pass primitives by value
Summary: @public Passes all `float`, `bool`, etc. by value, not by reference. Reviewed By: astreet Differential Revision: D13153500 fbshipit-source-id: 95529bc2efcff144044e2c25087915b2b7ede179
This commit is contained in:
committed by
Facebook Github Bot
parent
dd12907632
commit
8d5bbecd3d
@@ -52,7 +52,7 @@ bool YGFloatsEqual(const float a, const float b) {
|
||||
return yoga::isUndefined(a) && yoga::isUndefined(b);
|
||||
}
|
||||
|
||||
float YGFloatSanitize(const float& val) {
|
||||
float YGFloatSanitize(const float val) {
|
||||
return yoga::isUndefined(val) ? 0 : val;
|
||||
}
|
||||
|
||||
|
@@ -91,7 +91,7 @@ bool YGFloatArrayEqual(
|
||||
}
|
||||
|
||||
// This function returns 0 if YGFloatIsUndefined(val) is true and val otherwise
|
||||
float YGFloatSanitize(const float& val);
|
||||
float YGFloatSanitize(const float val);
|
||||
|
||||
// This function unwraps optional and returns YGUndefined if not defined or
|
||||
// op.value otherwise
|
||||
|
@@ -13,7 +13,7 @@ using namespace facebook;
|
||||
|
||||
YGFloatOptional YGNode::getLeadingPosition(
|
||||
const YGFlexDirection& axis,
|
||||
const float& axisSize) const {
|
||||
const float axisSize) const {
|
||||
if (YGFlexDirectionIsRow(axis)) {
|
||||
const YGValue* leadingPosition =
|
||||
YGComputedEdgeValue(style_.position, YGEdgeStart, &YGValueUndefined);
|
||||
@@ -32,7 +32,7 @@ YGFloatOptional YGNode::getLeadingPosition(
|
||||
|
||||
YGFloatOptional YGNode::getTrailingPosition(
|
||||
const YGFlexDirection& axis,
|
||||
const float& axisSize) const {
|
||||
const float axisSize) const {
|
||||
if (YGFlexDirectionIsRow(axis)) {
|
||||
const YGValue* trailingPosition =
|
||||
YGComputedEdgeValue(style_.position, YGEdgeEnd, &YGValueUndefined);
|
||||
@@ -67,7 +67,7 @@ bool YGNode::isTrailingPosDefined(const YGFlexDirection& axis) const {
|
||||
|
||||
YGFloatOptional YGNode::getLeadingMargin(
|
||||
const YGFlexDirection& axis,
|
||||
const float& widthSize) const {
|
||||
const float widthSize) const {
|
||||
if (YGFlexDirectionIsRow(axis) &&
|
||||
style_.margin[YGEdgeStart].unit != YGUnitUndefined) {
|
||||
return YGResolveValueMargin(style_.margin[YGEdgeStart], widthSize);
|
||||
@@ -80,7 +80,7 @@ YGFloatOptional YGNode::getLeadingMargin(
|
||||
|
||||
YGFloatOptional YGNode::getTrailingMargin(
|
||||
const YGFlexDirection& axis,
|
||||
const float& widthSize) const {
|
||||
const float widthSize) const {
|
||||
if (YGFlexDirectionIsRow(axis) &&
|
||||
style_.margin[YGEdgeEnd].unit != YGUnitUndefined) {
|
||||
return YGResolveValueMargin(style_.margin[YGEdgeEnd], widthSize);
|
||||
@@ -93,7 +93,7 @@ YGFloatOptional YGNode::getTrailingMargin(
|
||||
|
||||
YGFloatOptional YGNode::getMarginForAxis(
|
||||
const YGFlexDirection& axis,
|
||||
const float& widthSize) const {
|
||||
const float widthSize) const {
|
||||
return getLeadingMargin(axis, widthSize) + getTrailingMargin(axis, widthSize);
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ void YGNode::setLayoutDimension(float dimension, int index) {
|
||||
// +left or -right depending on which is defined.
|
||||
YGFloatOptional YGNode::relativePosition(
|
||||
const YGFlexDirection& axis,
|
||||
const float& axisSize) const {
|
||||
const float axisSize) const {
|
||||
if (isLeadingPositionDefined(axis)) {
|
||||
return getLeadingPosition(axis, axisSize);
|
||||
}
|
||||
@@ -453,7 +453,7 @@ float YGNode::getTrailingBorder(const YGFlexDirection& flexDirection) const {
|
||||
|
||||
YGFloatOptional YGNode::getLeadingPadding(
|
||||
const YGFlexDirection& axis,
|
||||
const float& widthSize) const {
|
||||
const float widthSize) const {
|
||||
const YGFloatOptional& paddingEdgeStart =
|
||||
YGResolveValue(style_.padding[YGEdgeStart], widthSize);
|
||||
if (YGFlexDirectionIsRow(axis) &&
|
||||
@@ -470,7 +470,7 @@ YGFloatOptional YGNode::getLeadingPadding(
|
||||
|
||||
YGFloatOptional YGNode::getTrailingPadding(
|
||||
const YGFlexDirection& axis,
|
||||
const float& widthSize) const {
|
||||
const float widthSize) const {
|
||||
if (YGFlexDirectionIsRow(axis) &&
|
||||
style_.padding[YGEdgeEnd].unit != YGUnitUndefined &&
|
||||
!YGResolveValue(style_.padding[YGEdgeEnd], widthSize).isUndefined() &&
|
||||
@@ -487,14 +487,14 @@ YGFloatOptional YGNode::getTrailingPadding(
|
||||
|
||||
YGFloatOptional YGNode::getLeadingPaddingAndBorder(
|
||||
const YGFlexDirection& axis,
|
||||
const float& widthSize) const {
|
||||
const float widthSize) const {
|
||||
return getLeadingPadding(axis, widthSize) +
|
||||
YGFloatOptional(getLeadingBorder(axis));
|
||||
}
|
||||
|
||||
YGFloatOptional YGNode::getTrailingPaddingAndBorder(
|
||||
const YGFlexDirection& axis,
|
||||
const float& widthSize) const {
|
||||
const float widthSize) const {
|
||||
return getTrailingPadding(axis, widthSize) +
|
||||
YGFloatOptional(getTrailingBorder(axis));
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ struct YGNode {
|
||||
|
||||
YGFloatOptional relativePosition(
|
||||
const YGFlexDirection& axis,
|
||||
const float& axisSize) const;
|
||||
const float axisSize) const;
|
||||
|
||||
public:
|
||||
YGNode() = default;
|
||||
@@ -139,35 +139,35 @@ struct YGNode {
|
||||
// Methods related to positions, margin, padding and border
|
||||
YGFloatOptional getLeadingPosition(
|
||||
const YGFlexDirection& axis,
|
||||
const float& axisSize) const;
|
||||
const float axisSize) const;
|
||||
bool isLeadingPositionDefined(const YGFlexDirection& axis) const;
|
||||
bool isTrailingPosDefined(const YGFlexDirection& axis) const;
|
||||
YGFloatOptional getTrailingPosition(
|
||||
const YGFlexDirection& axis,
|
||||
const float& axisSize) const;
|
||||
const float axisSize) const;
|
||||
YGFloatOptional getLeadingMargin(
|
||||
const YGFlexDirection& axis,
|
||||
const float& widthSize) const;
|
||||
const float widthSize) const;
|
||||
YGFloatOptional getTrailingMargin(
|
||||
const YGFlexDirection& axis,
|
||||
const float& widthSize) const;
|
||||
const float widthSize) const;
|
||||
float getLeadingBorder(const YGFlexDirection& flexDirection) const;
|
||||
float getTrailingBorder(const YGFlexDirection& flexDirection) const;
|
||||
YGFloatOptional getLeadingPadding(
|
||||
const YGFlexDirection& axis,
|
||||
const float& widthSize) const;
|
||||
const float widthSize) const;
|
||||
YGFloatOptional getTrailingPadding(
|
||||
const YGFlexDirection& axis,
|
||||
const float& widthSize) const;
|
||||
const float widthSize) const;
|
||||
YGFloatOptional getLeadingPaddingAndBorder(
|
||||
const YGFlexDirection& axis,
|
||||
const float& widthSize) const;
|
||||
const float widthSize) const;
|
||||
YGFloatOptional getTrailingPaddingAndBorder(
|
||||
const YGFlexDirection& axis,
|
||||
const float& widthSize) const;
|
||||
const float widthSize) const;
|
||||
YGFloatOptional getMarginForAxis(
|
||||
const YGFlexDirection& axis,
|
||||
const float& widthSize) const;
|
||||
const float widthSize) const;
|
||||
// Setters
|
||||
|
||||
void setContext(void* context) {
|
||||
|
@@ -1221,8 +1221,8 @@ static inline bool YGNodeIsLayoutDimDefined(
|
||||
static YGFloatOptional YGNodeBoundAxisWithinMinAndMax(
|
||||
const YGNodeRef node,
|
||||
const YGFlexDirection& axis,
|
||||
const float& value,
|
||||
const float& axisSize) {
|
||||
const float value,
|
||||
const float axisSize) {
|
||||
YGFloatOptional min;
|
||||
YGFloatOptional max;
|
||||
|
||||
@@ -2422,17 +2422,17 @@ static void YGResolveFlexibleLength(
|
||||
static void YGJustifyMainAxis(
|
||||
const YGNodeRef node,
|
||||
YGCollectFlexItemsRowValues& collectedFlexItemsValues,
|
||||
const uint32_t& startOfLineIndex,
|
||||
const uint32_t startOfLineIndex,
|
||||
const YGFlexDirection& mainAxis,
|
||||
const YGFlexDirection& crossAxis,
|
||||
const YGMeasureMode& measureModeMainDim,
|
||||
const YGMeasureMode& measureModeCrossDim,
|
||||
const float& mainAxisownerSize,
|
||||
const float& ownerWidth,
|
||||
const float& availableInnerMainDim,
|
||||
const float& availableInnerCrossDim,
|
||||
const float& availableInnerWidth,
|
||||
const bool& performLayout) {
|
||||
const float mainAxisownerSize,
|
||||
const float ownerWidth,
|
||||
const float availableInnerMainDim,
|
||||
const float availableInnerCrossDim,
|
||||
const float availableInnerWidth,
|
||||
const bool performLayout) {
|
||||
const YGStyle& style = node->getStyle();
|
||||
const float leadingPaddingAndBorderMain = YGUnwrapFloatOptional(
|
||||
node->getLeadingPaddingAndBorder(mainAxis, ownerWidth));
|
||||
|
Reference in New Issue
Block a user