From 92b76447b772e39d4ac209d25f123e9655be2f62 Mon Sep 17 00:00:00 2001 From: Sidharth Guglani Date: Fri, 17 Apr 2020 05:25:22 -0700 Subject: [PATCH] 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 --- yoga/YGLayout.h | 2 +- yoga/Yoga-internal.h | 8 ++++---- yoga/Yoga.cpp | 6 ++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/yoga/YGLayout.h b/yoga/YGLayout.h index 30b8dd76..b7604d8e 100644 --- a/yoga/YGLayout.h +++ b/yoga/YGLayout.h @@ -36,7 +36,7 @@ public: // 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; + YGDirection lastOwnerDirection = YGDirectionInherit; uint32_t nextCachedMeasurementsIndex = 0; std::array diff --git a/yoga/Yoga-internal.h b/yoga/Yoga-internal.h index 0b3368a0..1a22f24c 100644 --- a/yoga/Yoga-internal.h +++ b/yoga/Yoga-internal.h @@ -54,10 +54,10 @@ struct YGCachedMeasurement { float computedHeight; YGCachedMeasurement() - : availableWidth(0), - availableHeight(0), - widthMeasureMode((YGMeasureMode) -1), - heightMeasureMode((YGMeasureMode) -1), + : availableWidth(-1), + availableHeight(-1), + widthMeasureMode(YGMeasureModeUndefined), + heightMeasureMode(YGMeasureModeUndefined), computedWidth(-1), computedHeight(-1) {} diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp index d6f4a114..bb7da7bf 100644 --- a/yoga/Yoga.cpp +++ b/yoga/Yoga.cpp @@ -3821,8 +3821,10 @@ bool YGLayoutNodeInternal( if (needToVisitNode) { // Invalidate the cached results. layout->nextCachedMeasurementsIndex = 0; - layout->cachedLayout.widthMeasureMode = (YGMeasureMode) -1; - layout->cachedLayout.heightMeasureMode = (YGMeasureMode) -1; + layout->cachedLayout.availableWidth = -1; + layout->cachedLayout.availableHeight = -1; + layout->cachedLayout.widthMeasureMode = YGMeasureModeUndefined; + layout->cachedLayout.heightMeasureMode = YGMeasureModeUndefined; layout->cachedLayout.computedWidth = -1; layout->cachedLayout.computedHeight = -1; }