Roll back -ffast-math
Summary: @public `-ffast-math` does not have measurable performance benefits. By using `NaN` for *undefined* values again, we can squeeze `YGFloatOptional` into 32 bits. This will also enable us to store `YGValue` (or a variant of it) in 32 bits. Reviewed By: SidharthGuglani Differential Revision: D13119110 fbshipit-source-id: 4e6964240bf74ebc22d8783107b89d536a1a0842
This commit is contained in:
committed by
Facebook Github Bot
parent
b9972cee6e
commit
0962c5220c
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
@@ -9,28 +9,11 @@ namespace Facebook.Yoga
|
||||
{
|
||||
public static class YogaConstants
|
||||
{
|
||||
/**
|
||||
* Large positive number signifies that the property(float) is undefined. Earlier we used to have
|
||||
* YGundefined as NAN, but the downside of this is that we can't use -ffast-math compiler flag as
|
||||
* it assumes all floating-point calculation involve and result into finite numbers. For more
|
||||
* information regarding -ffast-math compiler flag in clang, have a look at
|
||||
* https://clang.llvm.org/docs/UsersManual.html#cmdoption-ffast-math
|
||||
*/
|
||||
public const float Undefined = 10E20F;
|
||||
public const float Undefined = float.NaN;
|
||||
|
||||
public static bool IsUndefined(float value)
|
||||
{
|
||||
// Value of a float in the case of it being not defined is 10.1E20. Earlier it used to be NAN,
|
||||
// the benefit of which
|
||||
// was that if NAN is involved in any mathematical expression the result was NAN. But since we
|
||||
// want to have `-ffast-math`
|
||||
// flag being used by compiler which assumes that the floating point values are not NAN and Inf,
|
||||
// we represent YGUndefined as 10.1E20.
|
||||
// But now if YGUndefined is involved in any mathematical operations this value(10.1E20) would
|
||||
// change.
|
||||
// So the following check makes sure that if the value is outside a range (-10E8, 10E8) then it
|
||||
// is undefined.
|
||||
return value >= 10E8F || value <= -10E8;
|
||||
return float.IsNaN(value);
|
||||
}
|
||||
|
||||
public static bool IsUndefined(YogaValue value)
|
||||
|
Reference in New Issue
Block a user