mirror of
https://github.com/status-im/react-native.git
synced 2025-01-14 03:26:07 +00:00
Made the acccessors method to return const references
Reviewed By: emilsjolander Differential Revision: D7321801 fbshipit-source-id: 9fc4da724bc2f58a0d95824ca3c0b5bf1690bccf
This commit is contained in:
parent
d4add3fc1c
commit
2ace555972
@ -14,7 +14,7 @@ YGFloatOptional::YGFloatOptional(const float& value)
|
||||
: value_(value), isUndefined_(false) {}
|
||||
YGFloatOptional::YGFloatOptional() : value_(0), isUndefined_(true) {}
|
||||
|
||||
float YGFloatOptional::getValue() const {
|
||||
const float& YGFloatOptional::getValue() const {
|
||||
if (isUndefined_) {
|
||||
// Abort, accessing a value of an undefined float optional
|
||||
std::cerr << "Tried to get value of an undefined YGFloatOptional\n";
|
||||
@ -28,7 +28,7 @@ void YGFloatOptional::setValue(const float& val) {
|
||||
isUndefined_ = false;
|
||||
}
|
||||
|
||||
bool YGFloatOptional::isUndefined() const {
|
||||
const bool& YGFloatOptional::isUndefined() const {
|
||||
return isUndefined_;
|
||||
}
|
||||
|
||||
|
@ -17,12 +17,12 @@ struct YGFloatOptional {
|
||||
// Program will terminate if the value of an undefined is accessed. Please
|
||||
// make sure to check if the optional is defined before calling this function.
|
||||
// To check if float optional is defined, use `isUndefined()`.
|
||||
float getValue() const;
|
||||
const float& getValue() const;
|
||||
|
||||
// Sets the value of float optional, and thus isUndefined is assigned false.
|
||||
void setValue(const float& val);
|
||||
|
||||
bool isUndefined() const;
|
||||
const bool& isUndefined() const;
|
||||
|
||||
bool operator==(const YGFloatOptional& op) const;
|
||||
bool operator!=(const YGFloatOptional& op) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user