Skip to content

Commit

Permalink
Addresses thread safety, GitHub issue facebook#769.
Browse files Browse the repository at this point in the history
See also: discussions in PR facebook#852 and facebook#786.

In addition to improving thread safety, it removes 8 bytes of heap per node.
  • Loading branch information
jpap committed Jan 17, 2019
1 parent 604a9a9 commit 13ebc70
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 60 deletions.
4 changes: 0 additions & 4 deletions yoga/YGLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@ struct YGLayout {
bool doesLegacyStretchFlagAffectsLayout : 1;
bool hadOverflow : 1;

uint32_t computedFlexBasisGeneration = 0;
YGFloatOptional computedFlexBasis = {};

// Instead of recomputing the entire layout every single time, we cache some
// information to break early when nothing changed
uint32_t generationCount = 0;
YGDirection lastOwnerDirection = (YGDirection) -1;

uint32_t nextCachedMeasurementsIndex = 0;
Expand Down
5 changes: 0 additions & 5 deletions yoga/YGNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,6 @@ void YGNode::setLayoutPosition(float position, int index) {
layout_.position[index] = position;
}

void YGNode::setLayoutComputedFlexBasisGeneration(
uint32_t computedFlexBasisGeneration) {
layout_.computedFlexBasisGeneration = computedFlexBasisGeneration;
}

void YGNode::setLayoutMeasuredDimension(float measuredDimension, int index) {
layout_.measuredDimensions[index] = measuredDimension;
}
Expand Down
2 changes: 0 additions & 2 deletions yoga/YGNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,6 @@ struct YGNode {
void setDirty(bool isDirty);
void setLayoutLastOwnerDirection(YGDirection direction);
void setLayoutComputedFlexBasis(const YGFloatOptional computedFlexBasis);
void setLayoutComputedFlexBasisGeneration(
uint32_t computedFlexBasisGeneration);
void setLayoutMeasuredDimension(float measuredDimension, int index);
void setLayoutHadOverflow(bool hadOverflow);
void setLayoutDimension(float dimension, int index);
Expand Down
Loading

0 comments on commit 13ebc70

Please sign in to comment.