Eliminate YGFloatOptional::getValue()
Summary: @public `YGFloatOptional::getValue()` has the unfortunate property of calling `std::exit` if the wrapped value is undefined. That forces `x.isUndefined() ? fallback : x.getValue()` as access pattern. Here, we replace that by introducing `YGFloatOptional::orElse(float)` which encapsulates that pattern. Other additions are `orElseGet([] { … })` and some extra operators. Reviewed By: SidharthGuglani Differential Revision: D13209152 fbshipit-source-id: 4e5deceaaaaf8eaed44846a8c152cc8b235e815c
This commit is contained in:
committed by
Facebook Github Bot
parent
ed3b54b603
commit
50ec35575f
@@ -43,7 +43,7 @@ static void appendFloatOptionalIfDefined(
|
||||
const string key,
|
||||
const YGFloatOptional num) {
|
||||
if (!num.isUndefined()) {
|
||||
appendFormatedString(base, "%s: %g; ", key.c_str(), num.getValue());
|
||||
appendFormatedString(base, "%s: %g; ", key.c_str(), num.unwrap());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,6 @@ appendNumberIfNotAuto(string* base, const string& key, const YGValue number) {
|
||||
|
||||
static void
|
||||
appendNumberIfNotZero(string* base, const string& str, const YGValue number) {
|
||||
|
||||
if (number.unit == YGUnitAuto) {
|
||||
base->append(str + ": auto; ");
|
||||
} else if (!YGFloatsEqual(number.value, 0)) {
|
||||
|
Reference in New Issue
Block a user