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
This commit is contained in:
Sidharth Guglani
2020-04-17 05:25:22 -07:00
committed by Facebook GitHub Bot
parent e637cf2d72
commit 92b76447b7
3 changed files with 9 additions and 7 deletions

View File

@@ -36,7 +36,7 @@ public:
// Instead of recomputing the entire layout every single time, we cache some // Instead of recomputing the entire layout every single time, we cache some
// information to break early when nothing changed // information to break early when nothing changed
uint32_t generationCount = 0; uint32_t generationCount = 0;
YGDirection lastOwnerDirection = (YGDirection) -1; YGDirection lastOwnerDirection = YGDirectionInherit;
uint32_t nextCachedMeasurementsIndex = 0; uint32_t nextCachedMeasurementsIndex = 0;
std::array<YGCachedMeasurement, YG_MAX_CACHED_RESULT_COUNT> std::array<YGCachedMeasurement, YG_MAX_CACHED_RESULT_COUNT>

View File

@@ -54,10 +54,10 @@ struct YGCachedMeasurement {
float computedHeight; float computedHeight;
YGCachedMeasurement() YGCachedMeasurement()
: availableWidth(0), : availableWidth(-1),
availableHeight(0), availableHeight(-1),
widthMeasureMode((YGMeasureMode) -1), widthMeasureMode(YGMeasureModeUndefined),
heightMeasureMode((YGMeasureMode) -1), heightMeasureMode(YGMeasureModeUndefined),
computedWidth(-1), computedWidth(-1),
computedHeight(-1) {} computedHeight(-1) {}

View File

@@ -3821,8 +3821,10 @@ bool YGLayoutNodeInternal(
if (needToVisitNode) { if (needToVisitNode) {
// Invalidate the cached results. // Invalidate the cached results.
layout->nextCachedMeasurementsIndex = 0; layout->nextCachedMeasurementsIndex = 0;
layout->cachedLayout.widthMeasureMode = (YGMeasureMode) -1; layout->cachedLayout.availableWidth = -1;
layout->cachedLayout.heightMeasureMode = (YGMeasureMode) -1; layout->cachedLayout.availableHeight = -1;
layout->cachedLayout.widthMeasureMode = YGMeasureModeUndefined;
layout->cachedLayout.heightMeasureMode = YGMeasureModeUndefined;
layout->cachedLayout.computedWidth = -1; layout->cachedLayout.computedWidth = -1;
layout->cachedLayout.computedHeight = -1; layout->cachedLayout.computedHeight = -1;
} }