Eliminate remaining YGStyle&
locals
Summary: @public Replaces local references to `YGStyle` objects, and assignment to `YGValue` members with direct assignment from temporaries. This should increase readability, and eliminate duplicated checks for *undefined* values. Reviewed By: astreet Differential Revision: D9083531 fbshipit-source-id: 11386be465352f5cb167b8195b7da432d0055d6f
This commit is contained in:
committed by
Facebook Github Bot
parent
45c44d293c
commit
8368338c93
@@ -654,19 +654,16 @@ struct StyleProp {
|
|||||||
const YGNodeRef node, const type paramName) { \
|
const YGNodeRef node, const type paramName) { \
|
||||||
if (node->getStyle().instanceName.value != YGFloatSanitize(paramName) || \
|
if (node->getStyle().instanceName.value != YGFloatSanitize(paramName) || \
|
||||||
node->getStyle().instanceName.unit != YGUnitPercent) { \
|
node->getStyle().instanceName.unit != YGUnitPercent) { \
|
||||||
YGStyle& style = node->getStyle(); \
|
node->getStyle().instanceName = YGFloatIsUndefined(paramName) \
|
||||||
style.instanceName.value = YGFloatSanitize(paramName); \
|
? YGValue{0, YGUnitAuto} \
|
||||||
style.instanceName.unit = \
|
: YGValue{paramName, YGUnitPercent}; \
|
||||||
YGFloatIsUndefined(paramName) ? YGUnitAuto : YGUnitPercent; \
|
|
||||||
node->markDirtyAndPropogate(); \
|
node->markDirtyAndPropogate(); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
void YGNodeStyleSet##name##Auto(const YGNodeRef node) { \
|
void YGNodeStyleSet##name##Auto(const YGNodeRef node) { \
|
||||||
if (node->getStyle().instanceName.unit != YGUnitAuto) { \
|
if (node->getStyle().instanceName.unit != YGUnitAuto) { \
|
||||||
YGStyle& style = node->getStyle(); \
|
node->getStyle().instanceName = {0, YGUnitAuto}; \
|
||||||
style.instanceName.value = 0; \
|
|
||||||
style.instanceName.unit = YGUnitAuto; \
|
|
||||||
node->markDirtyAndPropogate(); \
|
node->markDirtyAndPropogate(); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
@@ -699,9 +696,7 @@ struct StyleProp {
|
|||||||
#define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_AUTO_IMPL(type, name, instanceName) \
|
#define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_AUTO_IMPL(type, name, instanceName) \
|
||||||
void YGNodeStyleSet##name##Auto(const YGNodeRef node, const YGEdge edge) { \
|
void YGNodeStyleSet##name##Auto(const YGNodeRef node, const YGEdge edge) { \
|
||||||
if (node->getStyle().instanceName[edge].unit != YGUnitAuto) { \
|
if (node->getStyle().instanceName[edge].unit != YGUnitAuto) { \
|
||||||
YGStyle& style = node->getStyle(); \
|
node->getStyle().instanceName[edge] = {0, YGUnitAuto}; \
|
||||||
style.instanceName[edge].value = 0; \
|
|
||||||
style.instanceName[edge].unit = YGUnitAuto; \
|
|
||||||
node->markDirtyAndPropogate(); \
|
node->markDirtyAndPropogate(); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
@@ -918,19 +913,16 @@ void YGNodeStyleSetFlexBasisPercent(
|
|||||||
const float flexBasisPercent) {
|
const float flexBasisPercent) {
|
||||||
if (node->getStyle().flexBasis.value != flexBasisPercent ||
|
if (node->getStyle().flexBasis.value != flexBasisPercent ||
|
||||||
node->getStyle().flexBasis.unit != YGUnitPercent) {
|
node->getStyle().flexBasis.unit != YGUnitPercent) {
|
||||||
YGStyle& style = node->getStyle();
|
node->getStyle().flexBasis = YGFloatIsUndefined(flexBasisPercent)
|
||||||
style.flexBasis.value = YGFloatSanitize(flexBasisPercent);
|
? YGValue{0, YGUnitAuto}
|
||||||
style.flexBasis.unit =
|
: YGValue{flexBasisPercent, YGUnitPercent};
|
||||||
YGFloatIsUndefined(flexBasisPercent) ? YGUnitAuto : YGUnitPercent;
|
|
||||||
node->markDirtyAndPropogate();
|
node->markDirtyAndPropogate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) {
|
void YGNodeStyleSetFlexBasisAuto(const YGNodeRef node) {
|
||||||
if (node->getStyle().flexBasis.unit != YGUnitAuto) {
|
if (node->getStyle().flexBasis.unit != YGUnitAuto) {
|
||||||
YGStyle& style = node->getStyle();
|
node->getStyle().flexBasis = {0, YGUnitAuto};
|
||||||
style.flexBasis.value = 0;
|
|
||||||
style.flexBasis.unit = YGUnitAuto;
|
|
||||||
node->markDirtyAndPropogate();
|
node->markDirtyAndPropogate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2402,7 +2394,7 @@ static void YGJustifyMainAxis(
|
|||||||
const float& availableInnerCrossDim,
|
const float& availableInnerCrossDim,
|
||||||
const float& availableInnerWidth,
|
const float& availableInnerWidth,
|
||||||
const bool& performLayout) {
|
const bool& performLayout) {
|
||||||
const YGStyle style = node->getStyle();
|
const YGStyle& style = node->getStyle();
|
||||||
|
|
||||||
// If we are using "at most" rules in the main axis. Calculate the remaining
|
// If we are using "at most" rules in the main axis. Calculate the remaining
|
||||||
// space when constraint by the min size defined for the main axis.
|
// space when constraint by the min size defined for the main axis.
|
||||||
@@ -2488,7 +2480,7 @@ static void YGJustifyMainAxis(
|
|||||||
i < collectedFlexItemsValues.endOfLineIndex;
|
i < collectedFlexItemsValues.endOfLineIndex;
|
||||||
i++) {
|
i++) {
|
||||||
const YGNodeRef child = node->getChild(i);
|
const YGNodeRef child = node->getChild(i);
|
||||||
const YGStyle childStyle = child->getStyle();
|
const YGStyle& childStyle = child->getStyle();
|
||||||
const YGLayout childLayout = child->getLayout();
|
const YGLayout childLayout = child->getLayout();
|
||||||
if (childStyle.display == YGDisplayNone) {
|
if (childStyle.display == YGDisplayNone) {
|
||||||
continue;
|
continue;
|
||||||
|
Reference in New Issue
Block a user