Change NaN with large number
Summary: Changed NaN with large number to support `-ffast-math` compiler flag.For `-ffast-math` to work, all floating point numbers should be finite. Reason for not going with `FLT_MAX`, is that, it may cause number overflow during math operations. So thats why I opted for big number smaller than `FLT_MAX`. Earlier we used NaN, while NaN is involved in comparision the comparision operator behaves differently, it always returns false. Also operators like, fmaxf,fminf etc. have wierd beahviours. This diff takes care of those things as far as possible, and all tests are passing. Running ./instrumentation_tests/run instrumentation_tests/com/facebook/feed/ctacoalescing:ctacoalescing --class AttachmentCallToActionSelectorBenchmarkTest --benchmark --extra-arg iterations=100 shows the perf gain of 13-15% Reviewed By: emilsjolander Differential Revision: D6969537 fbshipit-source-id: bdc09eaf703e0d313ca65c25a4fb44c99203d9bf
This commit is contained in:
committed by
Facebook Github Bot
parent
b28292e454
commit
3a82d2b1a8
15
yoga/Yoga.h
15
yoga/Yoga.h
@@ -18,13 +18,14 @@
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
// Not defined in MSVC++
|
||||
#ifndef NAN
|
||||
static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
|
||||
#define NAN (*(const float *) __nan)
|
||||
#endif
|
||||
|
||||
#define YGUndefined NAN
|
||||
/** 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
|
||||
**/
|
||||
#define YGUndefined 10E20F
|
||||
|
||||
#include "YGEnums.h"
|
||||
#include "YGMacros.h"
|
||||
|
Reference in New Issue
Block a user