From 8f52fb24ecde47c1a366b47bb7cb0390369c340d Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Wed, 31 Mar 2021 21:29:13 -0700 Subject: [PATCH] Make mutation sorting more clear Summary: This is more insurance against future changes than fixing any existing bugs. In a very small number of cases it looks like this sorting isn't working, for reasons that are not easily reproducible (way less than 1 in 10000 times for me, if that) and not obvious, since we're sorting vectors in a canonical and straightforward way. Again, this insures that logic won't change in the future. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D27492936 fbshipit-source-id: 7f47e44ac1101915e1a0433c8f0a50a3c6a0c7b3 --- .../renderer/animations/LayoutAnimationKeyFrameManager.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h index 20c5a176b72..5bd85db70ef 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h +++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.h @@ -331,9 +331,12 @@ static inline bool shouldFirstComeBeforeSecondMutation( // Make sure that removes on the same level are sorted - highest indices // must come first. if (lhs.type == ShadowViewMutation::Type::Remove && - lhs.parentShadowView.tag == rhs.parentShadowView.tag && - lhs.index > rhs.index) { - return true; + lhs.parentShadowView.tag == rhs.parentShadowView.tag) { + if (lhs.index > rhs.index) { + return true; + } else { + return false; + } } }