From bca4e4c8a477082034a85464e6c2e02da4d54aac Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Sun, 23 Jun 2019 21:30:00 -0700 Subject: [PATCH] Fabric: Additional static asserts in Differentiator Summary: I am about to change the definition of ShadowView a bit, so I think we need to ensure that we don't regress move semantic. Reviewed By: JoshuaGross, sammy-SC Differential Revision: D15911453 fbshipit-source-id: ce2cd4cb2375ecb76295948a1e9b5d2e7fb80f38 --- .../fabric/mounting/Differentiator.cpp | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/ReactCommon/fabric/mounting/Differentiator.cpp b/ReactCommon/fabric/mounting/Differentiator.cpp index 84d4931c28a..54b78aafab7 100644 --- a/ReactCommon/fabric/mounting/Differentiator.cpp +++ b/ReactCommon/fabric/mounting/Differentiator.cpp @@ -115,6 +115,29 @@ static ShadowViewNodePair::List sliceChildShadowNodeViewPairs( return pairList; } +/* + * Before we start to diff, let's make sure all our core data structures are in + * good shape to deliver the best performance. + */ +static_assert( + std::is_move_constructible::value, + "`ShadowViewMutation` must be `move constructible`."); +static_assert( + std::is_move_constructible::value, + "`ShadowView` must be `move constructible`."); +static_assert( + std::is_move_constructible::value, + "`ShadowViewNodePair` must be `move constructible`."); +static_assert( + std::is_move_assignable::value, + "`ShadowViewMutation` must be `move assignable`."); +static_assert( + std::is_move_assignable::value, + "`ShadowView` must be `move assignable`."); +static_assert( + std::is_move_assignable::value, + "`ShadowViewNodePair` must be `move assignable`."); + static void calculateShadowViewMutations( ShadowViewMutation::List &mutations, ShadowView const &parentShadowView, @@ -183,7 +206,7 @@ static void calculateShadowViewMutations( auto const &newChildPair = newChildPairs[index]; insertMutations.push_back(ShadowViewMutation::InsertMutation( - parentShadowView, newChildPair.shadowView, index)); + parentShadowView, newChildPair.shadowView, index)); insertedPairs.insert({newChildPair.shadowView.tag, &newChildPair}); }