From e1c651340b17ab67e5eb6bac77c4a94ade8f08d5 Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Thu, 6 Dec 2018 07:35:08 -0800 Subject: [PATCH] Make equality operator for `YGValue` inlineable Summary: @public Makes `operator==` for `YGValue` an inline function. Reviewed By: SidharthGuglani Differential Revision: D13189356 fbshipit-source-id: 7fe61035acf635e22ebb1a1071925d6b3dad0616 --- ReactCommon/yoga/yoga/YGValue.cpp | 18 ------------------ ReactCommon/yoga/yoga/YGValue.h | 20 ++++++++++++++++++-- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/ReactCommon/yoga/yoga/YGValue.cpp b/ReactCommon/yoga/yoga/YGValue.cpp index 4bfe083d1..fcdd0c693 100644 --- a/ReactCommon/yoga/yoga/YGValue.cpp +++ b/ReactCommon/yoga/yoga/YGValue.cpp @@ -9,21 +9,3 @@ const YGValue YGValueZero = {0, YGUnitPoint}; const YGValue YGValueUndefined = {YGUndefined, YGUnitUndefined}; const YGValue YGValueAuto = {YGUndefined, YGUnitAuto}; - -bool operator==(const YGValue& lhs, const YGValue& rhs) { - if (lhs.unit != rhs.unit) { - return false; - } - - switch (lhs.unit) { - case YGUnitUndefined: - case YGUnitAuto: - return true; - default: - return lhs.value == rhs.value; - } -} - -bool operator!=(const YGValue& lhs, const YGValue& rhs) { - return !(lhs == rhs); -} diff --git a/ReactCommon/yoga/yoga/YGValue.h b/ReactCommon/yoga/yoga/YGValue.h index 803b8e786..4e43f7b2f 100644 --- a/ReactCommon/yoga/yoga/YGValue.h +++ b/ReactCommon/yoga/yoga/YGValue.h @@ -33,8 +33,24 @@ YG_EXTERN_C_END #ifdef __cplusplus -bool operator==(const YGValue& lhs, const YGValue& rhs); +inline bool operator==(const YGValue& lhs, const YGValue& rhs) { + if (lhs.unit != rhs.unit) { + return false; + } -bool operator!=(const YGValue& lhs, const YGValue& rhs); + switch (lhs.unit) { + case YGUnitUndefined: + case YGUnitAuto: + return true; + case YGUnitPoint: + case YGUnitPercent: + default: + return lhs.value == rhs.value; + } +} + +inline bool operator!=(const YGValue& lhs, const YGValue& rhs) { + return !(lhs == rhs); +} #endif