Skip to content

Commit

Permalink
not using templates for updating styles which are used via bitfield
Browse files Browse the repository at this point in the history
Summary:
We want completely remove usages of Bitfield as it uses templates which bloats binary size
This stack will reduce 2.2 Kb in binary size bringing it down to 61.3KB on armv7

In this diff we are removing usage of template while updating styles.

## Changelog:
[Internal][Yoga] : Not using templates for updating styles

Reviewed By: astreet

Differential Revision: D18519570

fbshipit-source-id: 2324088b8c63154f818b1da1edf24c0533e10082
  • Loading branch information
SidharthGuglani-zz authored and facebook-github-bot committed Nov 15, 2019
1 parent e523302 commit b3439a2
Showing 1 changed file with 40 additions and 14 deletions.
54 changes: 40 additions & 14 deletions ReactCommon/yoga/yoga/Yoga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,10 @@ void updateIndexedStyleProp(
YOGA_EXPORT void YGNodeStyleSetDirection(
const YGNodeRef node,
const YGDirection value) {
updateStyle<MSVC_HINT(direction)>(node, &YGStyle::direction, value);
if (node->getStyle().direction() != value) {
node->getStyle().direction() = value;
node->markDirtyAndPropogate();
}
}
YOGA_EXPORT YGDirection YGNodeStyleGetDirection(const YGNodeConstRef node) {
return node->getStyle().direction();
Expand All @@ -591,8 +594,10 @@ YOGA_EXPORT YGDirection YGNodeStyleGetDirection(const YGNodeConstRef node) {
YOGA_EXPORT void YGNodeStyleSetFlexDirection(
const YGNodeRef node,
const YGFlexDirection flexDirection) {
updateStyle<MSVC_HINT(flexDirection)>(
node, &YGStyle::flexDirection, flexDirection);
if (node->getStyle().flexDirection() != flexDirection) {
node->getStyle().flexDirection() = flexDirection;
node->markDirtyAndPropogate();
}
}
YOGA_EXPORT YGFlexDirection
YGNodeStyleGetFlexDirection(const YGNodeConstRef node) {
Expand All @@ -602,8 +607,10 @@ YGNodeStyleGetFlexDirection(const YGNodeConstRef node) {
YOGA_EXPORT void YGNodeStyleSetJustifyContent(
const YGNodeRef node,
const YGJustify justifyContent) {
updateStyle<MSVC_HINT(justifyContent)>(
node, &YGStyle::justifyContent, justifyContent);
if (node->getStyle().justifyContent() != justifyContent) {
node->getStyle().justifyContent() = justifyContent;
node->markDirtyAndPropogate();
}
}
YOGA_EXPORT YGJustify YGNodeStyleGetJustifyContent(const YGNodeConstRef node) {
return node->getStyle().justifyContent();
Expand All @@ -612,8 +619,10 @@ YOGA_EXPORT YGJustify YGNodeStyleGetJustifyContent(const YGNodeConstRef node) {
YOGA_EXPORT void YGNodeStyleSetAlignContent(
const YGNodeRef node,
const YGAlign alignContent) {
updateStyle<MSVC_HINT(alignContent)>(
node, &YGStyle::alignContent, alignContent);
if (node->getStyle().alignContent() != alignContent) {
node->getStyle().alignContent() = alignContent;
node->markDirtyAndPropogate();
}
}
YOGA_EXPORT YGAlign YGNodeStyleGetAlignContent(const YGNodeConstRef node) {
return node->getStyle().alignContent();
Expand All @@ -622,7 +631,10 @@ YOGA_EXPORT YGAlign YGNodeStyleGetAlignContent(const YGNodeConstRef node) {
YOGA_EXPORT void YGNodeStyleSetAlignItems(
const YGNodeRef node,
const YGAlign alignItems) {
updateStyle<MSVC_HINT(alignItems)>(node, &YGStyle::alignItems, alignItems);
if (node->getStyle().alignItems() != alignItems) {
node->getStyle().alignItems() = alignItems;
node->markDirtyAndPropogate();
}
}
YOGA_EXPORT YGAlign YGNodeStyleGetAlignItems(const YGNodeConstRef node) {
return node->getStyle().alignItems();
Expand All @@ -631,7 +643,10 @@ YOGA_EXPORT YGAlign YGNodeStyleGetAlignItems(const YGNodeConstRef node) {
YOGA_EXPORT void YGNodeStyleSetAlignSelf(
const YGNodeRef node,
const YGAlign alignSelf) {
updateStyle<MSVC_HINT(alignSelf)>(node, &YGStyle::alignSelf, alignSelf);
if (node->getStyle().alignSelf() != alignSelf) {
node->getStyle().alignSelf() = alignSelf;
node->markDirtyAndPropogate();
}
}
YOGA_EXPORT YGAlign YGNodeStyleGetAlignSelf(const YGNodeConstRef node) {
return node->getStyle().alignSelf();
Expand All @@ -640,8 +655,10 @@ YOGA_EXPORT YGAlign YGNodeStyleGetAlignSelf(const YGNodeConstRef node) {
YOGA_EXPORT void YGNodeStyleSetPositionType(
const YGNodeRef node,
const YGPositionType positionType) {
updateStyle<MSVC_HINT(positionType)>(
node, &YGStyle::positionType, positionType);
if (node->getStyle().positionType() != positionType) {
node->getStyle().positionType() = positionType;
node->markDirtyAndPropogate();
}
}
YOGA_EXPORT YGPositionType
YGNodeStyleGetPositionType(const YGNodeConstRef node) {
Expand All @@ -651,7 +668,10 @@ YGNodeStyleGetPositionType(const YGNodeConstRef node) {
YOGA_EXPORT void YGNodeStyleSetFlexWrap(
const YGNodeRef node,
const YGWrap flexWrap) {
updateStyle<MSVC_HINT(flexWrap)>(node, &YGStyle::flexWrap, flexWrap);
if (node->getStyle().flexWrap() != flexWrap) {
node->getStyle().flexWrap() = flexWrap;
node->markDirtyAndPropogate();
}
}
YOGA_EXPORT YGWrap YGNodeStyleGetFlexWrap(const YGNodeConstRef node) {
return node->getStyle().flexWrap();
Expand All @@ -660,7 +680,10 @@ YOGA_EXPORT YGWrap YGNodeStyleGetFlexWrap(const YGNodeConstRef node) {
YOGA_EXPORT void YGNodeStyleSetOverflow(
const YGNodeRef node,
const YGOverflow overflow) {
updateStyle<MSVC_HINT(overflow)>(node, &YGStyle::overflow, overflow);
if (node->getStyle().overflow() != overflow) {
node->getStyle().overflow() = overflow;
node->markDirtyAndPropogate();
}
}
YOGA_EXPORT YGOverflow YGNodeStyleGetOverflow(const YGNodeConstRef node) {
return node->getStyle().overflow();
Expand All @@ -669,7 +692,10 @@ YOGA_EXPORT YGOverflow YGNodeStyleGetOverflow(const YGNodeConstRef node) {
YOGA_EXPORT void YGNodeStyleSetDisplay(
const YGNodeRef node,
const YGDisplay display) {
updateStyle<MSVC_HINT(display)>(node, &YGStyle::display, display);
if (node->getStyle().display() != display) {
node->getStyle().display() = display;
node->markDirtyAndPropogate();
}
}
YOGA_EXPORT YGDisplay YGNodeStyleGetDisplay(const YGNodeConstRef node) {
return node->getStyle().display();
Expand Down

0 comments on commit b3439a2

Please sign in to comment.