guards instead of nested if
Summary: Replaces two nested if-blocks with guards. This is intended to help with restructuring this function in follow-ups. @public Reviewed By: priteshrnandgaonkar Differential Revision: D8785659 fbshipit-source-id: 7b9d63e9814b83b999397c016ad67ad348bb0f72
This commit is contained in:
committed by
Facebook Github Bot
parent
ede2888326
commit
966f5ece4a
@@ -47,8 +47,18 @@ static void YGTransferLayoutDirection(
|
||||
}
|
||||
|
||||
static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
||||
if (root->getHasNewLayout()) {
|
||||
if (auto obj = YGNodeJobject(root)->lockLocal()) {
|
||||
if (!root->getHasNewLayout()) {
|
||||
return;
|
||||
}
|
||||
auto obj = YGNodeJobject(root)->lockLocal();
|
||||
if (!obj) {
|
||||
YGLog(
|
||||
root,
|
||||
YGLogLevelError,
|
||||
"Java YGNode was GCed during layout calculation\n");
|
||||
return;
|
||||
}
|
||||
|
||||
static auto widthField = obj->getClass()->getField<jfloat>("mWidth");
|
||||
static auto heightField = obj->getClass()->getField<jfloat>("mHeight");
|
||||
static auto leftField = obj->getClass()->getField<jfloat>("mLeft");
|
||||
@@ -56,8 +66,7 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
||||
|
||||
static auto marginLeftField =
|
||||
obj->getClass()->getField<jfloat>("mMarginLeft");
|
||||
static auto marginTopField =
|
||||
obj->getClass()->getField<jfloat>("mMarginTop");
|
||||
static auto marginTopField = obj->getClass()->getField<jfloat>("mMarginTop");
|
||||
static auto marginRightField =
|
||||
obj->getClass()->getField<jfloat>("mMarginRight");
|
||||
static auto marginBottomField =
|
||||
@@ -74,8 +83,7 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
||||
|
||||
static auto borderLeftField =
|
||||
obj->getClass()->getField<jfloat>("mBorderLeft");
|
||||
static auto borderTopField =
|
||||
obj->getClass()->getField<jfloat>("mBorderTop");
|
||||
static auto borderTopField = obj->getClass()->getField<jfloat>("mBorderTop");
|
||||
static auto borderRightField =
|
||||
obj->getClass()->getField<jfloat>("mBorderRight");
|
||||
static auto borderBottomField =
|
||||
@@ -85,8 +93,7 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
||||
obj->getClass()->getField<jint>("mEdgeSetFlag");
|
||||
static auto hasNewLayoutField =
|
||||
obj->getClass()->getField<jboolean>("mHasNewLayout");
|
||||
static auto doesLegacyStretchBehaviour =
|
||||
obj->getClass()->getField<jboolean>(
|
||||
static auto doesLegacyStretchBehaviour = obj->getClass()->getField<jboolean>(
|
||||
"mDoesLegacyStretchFlagAffectsLayout");
|
||||
|
||||
/* Those flags needs be in sync with YogaNode.java */
|
||||
@@ -107,8 +114,7 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
||||
if ((hasEdgeSetFlag & MARGIN) == MARGIN) {
|
||||
obj->setFieldValue(
|
||||
marginLeftField, YGNodeLayoutGetMargin(root, YGEdgeLeft));
|
||||
obj->setFieldValue(
|
||||
marginTopField, YGNodeLayoutGetMargin(root, YGEdgeTop));
|
||||
obj->setFieldValue(marginTopField, YGNodeLayoutGetMargin(root, YGEdgeTop));
|
||||
obj->setFieldValue(
|
||||
marginRightField, YGNodeLayoutGetMargin(root, YGEdgeRight));
|
||||
obj->setFieldValue(
|
||||
@@ -129,8 +135,7 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
||||
if ((hasEdgeSetFlag & BORDER) == BORDER) {
|
||||
obj->setFieldValue(
|
||||
borderLeftField, YGNodeLayoutGetBorder(root, YGEdgeLeft));
|
||||
obj->setFieldValue(
|
||||
borderTopField, YGNodeLayoutGetBorder(root, YGEdgeTop));
|
||||
obj->setFieldValue(borderTopField, YGNodeLayoutGetBorder(root, YGEdgeTop));
|
||||
obj->setFieldValue(
|
||||
borderRightField, YGNodeLayoutGetBorder(root, YGEdgeRight));
|
||||
obj->setFieldValue(
|
||||
@@ -144,13 +149,6 @@ static void YGTransferLayoutOutputsRecursive(YGNodeRef root) {
|
||||
for (uint32_t i = 0; i < YGNodeGetChildCount(root); i++) {
|
||||
YGTransferLayoutOutputsRecursive(YGNodeGetChild(root, i));
|
||||
}
|
||||
} else {
|
||||
YGLog(
|
||||
root,
|
||||
YGLogLevelError,
|
||||
"Java YGNode was GCed during layout calculation\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void YGPrint(YGNodeRef node) {
|
||||
|
Reference in New Issue
Block a user