Make equality operator for YGValue
inlineable
Summary: @public Makes `operator==` for `YGValue` an inline function. Reviewed By: SidharthGuglani Differential Revision: D13439601 fbshipit-source-id: c5dd1f35c40f0ffa8224ee2f40ac7cc3cd8e3cf9
This commit is contained in:
committed by
Facebook Github Bot
parent
f23a669ed0
commit
e9078374c9
@@ -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);
|
||||
}
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user