Skip to content

Commit 49e16bd

Browse files
use default value of enums YGDirection and YGMeasureMode instead of -1
Summary: Changelog: [Internal][Yoga] YGDirection variable was initialized incorrectly by casting -1 to YGDirection. Changing it to default value of direction Same for YGMeasureMode. Reviewed By: pasqualeanatriello Differential Revision: D20869042 fbshipit-source-id: 7bfe490193321baae875ef6fb49a938851950c9f
1 parent 90f60a8 commit 49e16bd

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

ReactCommon/yoga/yoga/YGLayout.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct YGLayout {
3636
// Instead of recomputing the entire layout every single time, we cache some
3737
// information to break early when nothing changed
3838
uint32_t generationCount = 0;
39-
YGDirection lastOwnerDirection = (YGDirection) -1;
39+
YGDirection lastOwnerDirection = YGDirectionInherit;
4040

4141
uint32_t nextCachedMeasurementsIndex = 0;
4242
std::array<YGCachedMeasurement, YG_MAX_CACHED_RESULT_COUNT>

ReactCommon/yoga/yoga/Yoga-internal.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ struct YGCachedMeasurement {
5454
float computedHeight;
5555

5656
YGCachedMeasurement()
57-
: availableWidth(0),
58-
availableHeight(0),
59-
widthMeasureMode((YGMeasureMode) -1),
60-
heightMeasureMode((YGMeasureMode) -1),
57+
: availableWidth(-1),
58+
availableHeight(-1),
59+
widthMeasureMode(YGMeasureModeUndefined),
60+
heightMeasureMode(YGMeasureModeUndefined),
6161
computedWidth(-1),
6262
computedHeight(-1) {}
6363

ReactCommon/yoga/yoga/Yoga.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3821,8 +3821,10 @@ bool YGLayoutNodeInternal(
38213821
if (needToVisitNode) {
38223822
// Invalidate the cached results.
38233823
layout->nextCachedMeasurementsIndex = 0;
3824-
layout->cachedLayout.widthMeasureMode = (YGMeasureMode) -1;
3825-
layout->cachedLayout.heightMeasureMode = (YGMeasureMode) -1;
3824+
layout->cachedLayout.availableWidth = -1;
3825+
layout->cachedLayout.availableHeight = -1;
3826+
layout->cachedLayout.widthMeasureMode = YGMeasureModeUndefined;
3827+
layout->cachedLayout.heightMeasureMode = YGMeasureModeUndefined;
38263828
layout->cachedLayout.computedWidth = -1;
38273829
layout->cachedLayout.computedHeight = -1;
38283830
}

0 commit comments

Comments
 (0)