Skip to content

Commit

Permalink
Inline YGFloatOptional completely
Browse files Browse the repository at this point in the history
Summary:
@public
`YGFLoatOptional` only contains trivial functionality. Make it header-only.

Reviewed By: SidharthGuglani

Differential Revision: D13439609

fbshipit-source-id: 3f3c6c3a15e05ac55da2af30eb629f786ecb90a9
  • Loading branch information
davidaurelio authored and facebook-github-bot committed Dec 13, 2018
1 parent 236bcc1 commit 96d93f2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 59 deletions.
49 changes: 0 additions & 49 deletions yoga/YGFloatOptional.cpp

This file was deleted.

39 changes: 29 additions & 10 deletions yoga/YGFloatOptional.h
Expand Up @@ -8,6 +8,7 @@

#include <cmath>
#include <limits>
#include "Yoga-internal.h"

struct YGFloatOptional {
private:
Expand All @@ -18,22 +19,40 @@ 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_;
}

bool isUndefined() const {
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);
}
};

0 comments on commit 96d93f2

Please sign in to comment.