Use bitfields for YGLayout
and YGNode
Summary: @public Further heap size reductions by using bitfields in `YGLayout` and `YGNode`. Reviewed By: SidharthGuglani Differential Revision: D13466325 fbshipit-source-id: ddcef0a1b3822e7449fe485d99c920d54139c893
This commit is contained in:
committed by
Facebook Github Bot
parent
885b4cbdfb
commit
f6415889ca
@@ -17,11 +17,13 @@ struct YGLayout {
|
|||||||
std::array<float, 6> margin = {};
|
std::array<float, 6> margin = {};
|
||||||
std::array<float, 6> border = {};
|
std::array<float, 6> border = {};
|
||||||
std::array<float, 6> padding = {};
|
std::array<float, 6> padding = {};
|
||||||
YGDirection direction = YGDirectionInherit;
|
YGDirection direction : 2;
|
||||||
|
bool didUseLegacyFlag : 1;
|
||||||
|
bool doesLegacyStretchFlagAffectsLayout : 1;
|
||||||
|
bool hadOverflow : 1;
|
||||||
|
|
||||||
uint32_t computedFlexBasisGeneration = 0;
|
uint32_t computedFlexBasisGeneration = 0;
|
||||||
YGFloatOptional computedFlexBasis = {};
|
YGFloatOptional computedFlexBasis = {};
|
||||||
bool hadOverflow = false;
|
|
||||||
|
|
||||||
// Instead of recomputing the entire layout every single time, we
|
// Instead of recomputing the entire layout every single time, we
|
||||||
// cache some information to break early when nothing changed
|
// cache some information to break early when nothing changed
|
||||||
@@ -34,10 +36,12 @@ struct YGLayout {
|
|||||||
std::array<float, 2> measuredDimensions = kYGDefaultDimensionValues;
|
std::array<float, 2> measuredDimensions = kYGDefaultDimensionValues;
|
||||||
|
|
||||||
YGCachedMeasurement cachedLayout = YGCachedMeasurement();
|
YGCachedMeasurement cachedLayout = YGCachedMeasurement();
|
||||||
bool didUseLegacyFlag = false;
|
|
||||||
bool doesLegacyStretchFlagAffectsLayout = false;
|
|
||||||
|
|
||||||
YGLayout() = default;
|
YGLayout()
|
||||||
|
: direction(YGDirectionInherit),
|
||||||
|
didUseLegacyFlag(false),
|
||||||
|
doesLegacyStretchFlagAffectsLayout(false),
|
||||||
|
hadOverflow(false) {}
|
||||||
|
|
||||||
bool operator==(YGLayout layout) const;
|
bool operator==(YGLayout layout) const;
|
||||||
bool operator!=(YGLayout layout) const {
|
bool operator!=(YGLayout layout) const {
|
||||||
|
@@ -15,9 +15,10 @@ struct YGNode {
|
|||||||
private:
|
private:
|
||||||
void* context_ = nullptr;
|
void* context_ = nullptr;
|
||||||
YGPrintFunc print_ = nullptr;
|
YGPrintFunc print_ = nullptr;
|
||||||
bool hasNewLayout_ = true;
|
bool hasNewLayout_ : 1;
|
||||||
bool isReferenceBaseline_ = false;
|
bool isReferenceBaseline_ : 1;
|
||||||
YGNodeType nodeType_ = YGNodeTypeDefault;
|
bool isDirty_ : 1;
|
||||||
|
YGNodeType nodeType_ : 1;
|
||||||
YGMeasureFunc measure_ = nullptr;
|
YGMeasureFunc measure_ = nullptr;
|
||||||
YGBaselineFunc baseline_ = nullptr;
|
YGBaselineFunc baseline_ = nullptr;
|
||||||
YGDirtiedFunc dirtied_ = nullptr;
|
YGDirtiedFunc dirtied_ = nullptr;
|
||||||
@@ -27,7 +28,6 @@ struct YGNode {
|
|||||||
YGNodeRef owner_ = nullptr;
|
YGNodeRef owner_ = nullptr;
|
||||||
YGVector children_ = {};
|
YGVector children_ = {};
|
||||||
YGConfigRef config_ = nullptr;
|
YGConfigRef config_ = nullptr;
|
||||||
bool isDirty_ = false;
|
|
||||||
std::array<YGValue, 2> resolvedDimensions_ = {
|
std::array<YGValue, 2> resolvedDimensions_ = {
|
||||||
{YGValueUndefined, YGValueUndefined}};
|
{YGValueUndefined, YGValueUndefined}};
|
||||||
|
|
||||||
@@ -36,7 +36,11 @@ struct YGNode {
|
|||||||
const float axisSize) const;
|
const float axisSize) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
YGNode() = default;
|
YGNode()
|
||||||
|
: hasNewLayout_(true),
|
||||||
|
isReferenceBaseline_(false),
|
||||||
|
isDirty_(false),
|
||||||
|
nodeType_(YGNodeTypeDefault) {}
|
||||||
~YGNode() = default; // cleanup of owner/children relationships in YGNodeFree
|
~YGNode() = default; // cleanup of owner/children relationships in YGNodeFree
|
||||||
explicit YGNode(const YGConfigRef newConfig) : config_(newConfig){};
|
explicit YGNode(const YGConfigRef newConfig) : config_(newConfig){};
|
||||||
YGNode(const YGNode& node) = default;
|
YGNode(const YGNode& node) = default;
|
||||||
|
Reference in New Issue
Block a user