FloatOptional GCC build fix and more constexpr (#1411)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1411 X-link: https://github.com/facebook/react-native/pull/39796 Pull Request resolved: https://github.com/facebook/yoga/pull/1414 GCC flags that `isUndefined()` is not declared `constexpr` but that `unwrapOrDefault()` is. `std::isnan` is not constexpr until C++ 23 (because we cannot have nice things), so I made `yoga::isUndefined()` constexpr, using the same code `std::isnan()` boils down to. I then made `FloatOptional` depend on `Comparison.h` (instead of the other way around), so we can use it. Note that the use of the `std::floating_point` concept here requires the libc++ bump in the previous diff in the stack. Reviewed By: yungsters Differential Revision: D49896837 fbshipit-source-id: 61e2bbbfedecffd007a12d42d998e43d3cf5119c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f700e1335c
commit
7fe6e345a7
@@ -563,10 +563,10 @@ static void measureNodeWithMeasureFunc(
|
||||
// We want to make sure we don't call measure with negative size
|
||||
const float innerWidth = yoga::isUndefined(availableWidth)
|
||||
? availableWidth
|
||||
: yoga::maxOrDefined(0, availableWidth - paddingAndBorderAxisRow);
|
||||
: yoga::maxOrDefined(0.0f, availableWidth - paddingAndBorderAxisRow);
|
||||
const float innerHeight = yoga::isUndefined(availableHeight)
|
||||
? availableHeight
|
||||
: yoga::maxOrDefined(0, availableHeight - paddingAndBorderAxisColumn);
|
||||
: yoga::maxOrDefined(0.0f, availableHeight - paddingAndBorderAxisColumn);
|
||||
|
||||
if (widthMeasureMode == MeasureMode::Exactly &&
|
||||
heightMeasureMode == MeasureMode::Exactly) {
|
||||
@@ -1223,7 +1223,7 @@ static void justifyMainAxis(
|
||||
const float occupiedSpaceByChildNodes =
|
||||
availableInnerMainDim - flexLine.layout.remainingFreeSpace;
|
||||
flexLine.layout.remainingFreeSpace = yoga::maxOrDefined(
|
||||
0, minAvailableMainDim - occupiedSpaceByChildNodes);
|
||||
0.0f, minAvailableMainDim - occupiedSpaceByChildNodes);
|
||||
} else {
|
||||
flexLine.layout.remainingFreeSpace = 0;
|
||||
}
|
||||
@@ -1260,7 +1260,7 @@ static void justifyMainAxis(
|
||||
case Justify::SpaceBetween:
|
||||
if (flexLine.itemsInFlow.size() > 1) {
|
||||
betweenMainDim +=
|
||||
yoga::maxOrDefined(flexLine.layout.remainingFreeSpace, 0) /
|
||||
yoga::maxOrDefined(flexLine.layout.remainingFreeSpace, 0.0f) /
|
||||
static_cast<float>(flexLine.itemsInFlow.size() - 1);
|
||||
}
|
||||
break;
|
||||
|
Reference in New Issue
Block a user