From a56b67fa9bc5db755273efd828bb71fc66147f0a Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Thu, 13 Dec 2018 07:09:31 -0800 Subject: [PATCH] Inline `YGFloatOptional` completely Summary: @public `YGFLoatOptional` only contains trivial functionality. Make it header-only. Reviewed By: SidharthGuglani Differential Revision: D13439609 fbshipit-source-id: 3f3c6c3a15e05ac55da2af30eb629f786ecb90a9 --- React/React.xcodeproj/project.pbxproj | 4 -- ReactCommon/yoga/yoga/YGFloatOptional.cpp | 49 ----------------------- ReactCommon/yoga/yoga/YGFloatOptional.h | 39 +++++++++++++----- 3 files changed, 29 insertions(+), 63 deletions(-) delete mode 100644 ReactCommon/yoga/yoga/YGFloatOptional.cpp diff --git a/React/React.xcodeproj/project.pbxproj b/React/React.xcodeproj/project.pbxproj index 3a8aceedefa..f458eb9927a 100644 --- a/React/React.xcodeproj/project.pbxproj +++ b/React/React.xcodeproj/project.pbxproj @@ -846,8 +846,6 @@ 53D1239F1FBF1EFB001B8A10 /* Yoga-internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 53CBF1851FB4FE80002CBB31 /* Yoga-internal.h */; }; 53D123A01FBF1EFF001B8A10 /* Yoga.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53CBF1871FB4FE80002CBB31 /* Yoga.cpp */; }; 53D123A11FBF1EFF001B8A10 /* Yoga.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53CBF1871FB4FE80002CBB31 /* Yoga.cpp */; }; - 53DEF6EA205AE5A0006A3890 /* YGFloatOptional.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53DEF6E6205AE59B006A3890 /* YGFloatOptional.cpp */; }; - 53DEF6EB205AE5A1006A3890 /* YGFloatOptional.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53DEF6E6205AE59B006A3890 /* YGFloatOptional.cpp */; }; 53DEF6EC205AE5A6006A3890 /* YGFloatOptional.h in Headers */ = {isa = PBXBuildFile; fileRef = 53DEF6E7205AE59C006A3890 /* YGFloatOptional.h */; }; 53DEF6ED205AE5A7006A3890 /* YGFloatOptional.h in Headers */ = {isa = PBXBuildFile; fileRef = 53DEF6E7205AE59C006A3890 /* YGFloatOptional.h */; }; 53EC85E21FDEC75F0051B2B5 /* YGNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53EC85DF1FDEC75A0051B2B5 /* YGNode.cpp */; }; @@ -4376,7 +4374,6 @@ files = ( AC6B69E721B146B400B2B68A /* YGValue.cpp in Sources */, AC8360D121B025BC00FC46B9 /* YGConfig.cpp in Sources */, - 53DEF6EA205AE5A0006A3890 /* YGFloatOptional.cpp in Sources */, 53D123A01FBF1EFF001B8A10 /* Yoga.cpp in Sources */, 5352C5752038FF9500A3B97E /* YGStyle.cpp in Sources */, 53EC85E21FDEC75F0051B2B5 /* YGNode.cpp in Sources */, @@ -4393,7 +4390,6 @@ files = ( AC6B69EA21B146E700B2B68A /* YGValue.cpp in Sources */, BA0501B02109DD1800A6BBC4 /* YGConfig.cpp in Sources */, - 53DEF6EB205AE5A1006A3890 /* YGFloatOptional.cpp in Sources */, 53D123A11FBF1EFF001B8A10 /* Yoga.cpp in Sources */, 5352C5762038FF9700A3B97E /* YGStyle.cpp in Sources */, 53EC85E31FDEC75F0051B2B5 /* YGNode.cpp in Sources */, diff --git a/ReactCommon/yoga/yoga/YGFloatOptional.cpp b/ReactCommon/yoga/yoga/YGFloatOptional.cpp deleted file mode 100644 index d202d4d5419..00000000000 --- a/ReactCommon/yoga/yoga/YGFloatOptional.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the LICENSE - * file in the root directory of this source tree. - */ -#include "YGFloatOptional.h" -#include -#include -#include "Yoga-internal.h" -#include "Yoga.h" - -using namespace facebook; - -bool YGFloatOptional::operator==(YGFloatOptional op) const { - return value_ == op.value_ || (isUndefined() && op.isUndefined()); -} - -bool YGFloatOptional::operator!=(YGFloatOptional op) const { - return !(*this == op); -} - -bool YGFloatOptional::operator==(float val) const { - return value_ == val || (isUndefined() && yoga::isUndefined(val)); -} - -bool YGFloatOptional::operator!=(float val) const { - return !(*this == val); -} - -YGFloatOptional YGFloatOptional::operator+(YGFloatOptional op) const { - return YGFloatOptional{value_ + op.value_}; -} - -bool YGFloatOptional::operator>(YGFloatOptional op) const { - return value_ > op.value_; -} - -bool YGFloatOptional::operator<(YGFloatOptional op) const { - return value_ < op.value_; -} - -bool YGFloatOptional::operator>=(YGFloatOptional op) const { - return *this > op || *this == op; -} - -bool YGFloatOptional::operator<=(YGFloatOptional op) const { - return *this < op || *this == op; -} diff --git a/ReactCommon/yoga/yoga/YGFloatOptional.h b/ReactCommon/yoga/yoga/YGFloatOptional.h index b49747982fb..44cf344ef69 100644 --- a/ReactCommon/yoga/yoga/YGFloatOptional.h +++ b/ReactCommon/yoga/yoga/YGFloatOptional.h @@ -8,6 +8,7 @@ #include #include +#include "Yoga-internal.h" struct YGFloatOptional { private: @@ -18,7 +19,7 @@ struct YGFloatOptional { constexpr YGFloatOptional() = default; // returns the wrapped value, or a value x with YGIsUndefined(x) == true - float unwrap() const { + constexpr float unwrap() const { return value_; } @@ -26,14 +27,32 @@ struct YGFloatOptional { return std::isnan(value_); } - YGFloatOptional operator+(YGFloatOptional op) const; - bool operator>(YGFloatOptional op) const; - bool operator<(YGFloatOptional op) const; - bool operator>=(YGFloatOptional op) const; - bool operator<=(YGFloatOptional op) const; - bool operator==(YGFloatOptional op) const; - bool operator!=(YGFloatOptional op) const; + YGFloatOptional operator+(YGFloatOptional op) const { + return YGFloatOptional{value_ + op.value_}; + } + bool operator>(YGFloatOptional op) const { + return value_ > op.value_; + } + bool operator<(YGFloatOptional op) const { + return value_ < op.value_; + } + bool operator>=(YGFloatOptional op) const { + return *this > op || *this == op; + } + bool operator<=(YGFloatOptional op) const { + return *this < op || *this == op; + } + bool operator==(YGFloatOptional op) const { + return value_ == op.value_ || (isUndefined() && op.isUndefined()); + } + bool operator!=(YGFloatOptional op) const { + return !(*this == op); + } - bool operator==(float val) const; - bool operator!=(float val) const; + bool operator==(float val) const { + return value_ == val || (isUndefined() && yoga::isUndefined(val)); + } + bool operator!=(float val) const { + return !(*this == val); + } };