Remove cast from detail::Values to std::array<YGValue

Summary:
@public

When switching to `CompactValue`, casting edges or dimensions to `std::array<YGValue, ...>` will do actual work.
In order to avoid that from happening implicitely, we remove the casting operator.

Reviewed By: SidharthGuglani

Differential Revision: D13464292

fbshipit-source-id: 217065b001a63cfa8adde715063682c583007a4d
This commit is contained in:
David Aurelio
2018-12-14 09:20:27 -08:00
committed by Facebook Github Bot
parent 3df41aefdb
commit 8461aeaef0
3 changed files with 6 additions and 15 deletions

View File

@@ -20,7 +20,8 @@ static void indent(string& base, uint32_t level) {
}
}
static bool areFourValuesEqual(const std::array<YGValue, YGEdgeCount>& four) {
static bool areFourValuesEqual(
const facebook::yoga::detail::Values<YGEdgeCount>& four) {
return YGValueEqual(four[0], four[1]) && YGValueEqual(four[0], four[2]) &&
YGValueEqual(four[0], four[3]);
}
@@ -81,7 +82,7 @@ appendNumberIfNotZero(string& base, const string& str, const YGValue number) {
static void appendEdges(
string& base,
const string& key,
const std::array<YGValue, YGEdgeCount>& edges) {
const facebook::yoga::detail::Values<YGEdgeCount>& edges) {
if (areFourValuesEqual(edges)) {
appendNumberIfNotZero(base, key, edges[YGEdgeLeft]);
} else {
@@ -95,7 +96,7 @@ static void appendEdges(
static void appendEdgeIfNotUndefined(
string& base,
const string& str,
const std::array<YGValue, YGEdgeCount>& edges,
const facebook::yoga::detail::Values<YGEdgeCount>& edges,
const YGEdge edge) {
appendNumberIfNotUndefined(
base, str, *YGComputedEdgeValue(edges, edge, &YGValueUndefined));

View File

@@ -103,12 +103,6 @@ class Values {
values_.fill(defaultValue);
}
operator const std::array<YGValue, Size>&() const noexcept {
return values_;
}
operator std::array<YGValue, Size>&() noexcept {
return values_;
}
const YGValue& operator[](size_t i) const noexcept {
return values_[i];
}
@@ -136,10 +130,6 @@ class Values {
}
Values& operator=(const Values& other) = default;
Values& operator=(const std::array<YGValue, Size>& other) noexcept {
values_ = other;
return *this;
}
};
} // namespace detail
@@ -153,6 +143,6 @@ static const float kWebDefaultFlexShrink = 1.0f;
extern bool YGFloatsEqual(const float a, const float b);
extern bool YGValueEqual(const YGValue a, const YGValue b);
extern const YGValue* YGComputedEdgeValue(
const std::array<YGValue, YGEdgeCount>& edges,
const facebook::yoga::detail::Values<YGEdgeCount>& edges,
const YGEdge edge,
const YGValue* const defaultValue);

View File

@@ -103,7 +103,7 @@ bool YGFloatIsUndefined(const float value) {
}
const YGValue* YGComputedEdgeValue(
const std::array<YGValue, YGEdgeCount>& edges,
const facebook::yoga::detail::Values<YGEdgeCount>& edges,
const YGEdge edge,
const YGValue* const defaultValue) {
if (edges[edge].unit != YGUnitUndefined) {