Skip to content

Commit bca4e4c

Browse files
sherginfacebook-github-bot
authored andcommitted
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
1 parent 58cd046 commit bca4e4c

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

ReactCommon/fabric/mounting/Differentiator.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,29 @@ static ShadowViewNodePair::List sliceChildShadowNodeViewPairs(
115115
return pairList;
116116
}
117117

118+
/*
119+
* Before we start to diff, let's make sure all our core data structures are in
120+
* good shape to deliver the best performance.
121+
*/
122+
static_assert(
123+
std::is_move_constructible<ShadowViewMutation>::value,
124+
"`ShadowViewMutation` must be `move constructible`.");
125+
static_assert(
126+
std::is_move_constructible<ShadowView>::value,
127+
"`ShadowView` must be `move constructible`.");
128+
static_assert(
129+
std::is_move_constructible<ShadowViewNodePair>::value,
130+
"`ShadowViewNodePair` must be `move constructible`.");
131+
static_assert(
132+
std::is_move_assignable<ShadowViewMutation>::value,
133+
"`ShadowViewMutation` must be `move assignable`.");
134+
static_assert(
135+
std::is_move_assignable<ShadowView>::value,
136+
"`ShadowView` must be `move assignable`.");
137+
static_assert(
138+
std::is_move_assignable<ShadowViewNodePair>::value,
139+
"`ShadowViewNodePair` must be `move assignable`.");
140+
118141
static void calculateShadowViewMutations(
119142
ShadowViewMutation::List &mutations,
120143
ShadowView const &parentShadowView,
@@ -183,7 +206,7 @@ static void calculateShadowViewMutations(
183206
auto const &newChildPair = newChildPairs[index];
184207

185208
insertMutations.push_back(ShadowViewMutation::InsertMutation(
186-
parentShadowView, newChildPair.shadowView, index));
209+
parentShadowView, newChildPair.shadowView, index));
187210

188211
insertedPairs.insert({newChildPair.shadowView.tag, &newChildPair});
189212
}

0 commit comments

Comments
 (0)