From 668ce510bddcb5719e28652ce09d4be7c9708a27 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Thu, 9 Sep 2021 11:55:31 -0700 Subject: [PATCH] Avoid copy in LayoutAnimationDriver Summary: changelog: [internal] Avoid unnecessary copy of `ShadowViewMutation` and `ShadowView`. Reviewed By: RSNara Differential Revision: D30756214 fbshipit-source-id: 39c44dd60582e6c111986df482613212e25739d7 --- .../renderer/animations/LayoutAnimationDriver.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp index c1eb2747c63..131c034cb38 100644 --- a/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp +++ b/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp @@ -55,19 +55,12 @@ void LayoutAnimationDriver::animationMutationsForFrame( animationInterpolationFactor, baselineShadowView, finalShadowView); // Create the mutation instruction - auto updateMutation = ShadowViewMutation::UpdateMutation( - keyframe.viewPrev, mutatedShadowView); + mutationsList.emplace_back(ShadowViewMutation::UpdateMutation( + keyframe.viewPrev, mutatedShadowView)); - // All generated Update mutations must have an "old" and "new" - // ShadowView. Checking for nonzero tag doesn't guarantee that the views - // are valid/correct, just that something is there. - react_native_assert(updateMutation.oldChildShadowView.tag > 0); - react_native_assert(updateMutation.newChildShadowView.tag > 0); - - mutationsList.push_back(updateMutation); PrintMutationInstruction("Animation Progress:", updateMutation); - keyframe.viewPrev = mutatedShadowView; + keyframe.viewPrev = std::move(mutatedShadowView); if (animationTimeProgressLinear < 1) { incompleteAnimations++;