2727
2828namespace facebook ::react {
2929
30+ namespace {
31+
3032enum class ReparentMode { Flatten, Unflatten };
3133
3234#ifdef DEBUG_LOGS_DIFFER
33- static std::ostream& operator <<(
34- std::ostream& out,
35- const ShadowViewNodePair& pair) {
35+ std::ostream& operator <<(std::ostream& out, const ShadowViewNodePair& pair) {
3636 out << pair.shadowView .tag ;
3737 if (!pair.isConcreteView ) {
3838 out << ' \' ' ;
@@ -43,7 +43,7 @@ static std::ostream& operator<<(
4343 return out;
4444}
4545
46- static std::ostream& operator <<(
46+ std::ostream& operator <<(
4747 std::ostream& out,
4848 std::vector<ShadowViewNodePair*> vec) {
4949 for (int i = 0 ; i < vec.size (); i++) {
@@ -54,11 +54,9 @@ static std::ostream& operator<<(
5454 }
5555 return out;
5656}
57- #endif
5857
59- #ifdef DEBUG_LOGS_DIFFER
6058template <typename KeyT, typename ValueT>
61- static std::ostream& operator <<(
59+ std::ostream& operator <<(
6260 std::ostream& out,
6361 const std::unordered_map<KeyT, ValueT>& map) {
6462 auto it = map.begin ();
@@ -78,8 +76,7 @@ static std::ostream& operator<<(
7876 * possible. This can account for adding parent LayoutMetrics that are
7977 * important to take into account, but tricky, in (un)flattening cases.
8078 */
81- static std::vector<ShadowViewNodePair*>
82- sliceChildShadowNodeViewPairsFromViewNodePair (
79+ std::vector<ShadowViewNodePair*> sliceChildShadowNodeViewPairsFromViewNodePair (
8380 const ShadowViewNodePair& shadowViewNodePair,
8481 ViewNodePairScope& scope,
8582 bool allowFlattened,
@@ -97,7 +94,7 @@ sliceChildShadowNodeViewPairsFromViewNodePair(
9794 * `skipUnchangedChildrenInDifferentiator`, children that are the same node in
9895 * both trees are left out when possible: they produce no mutations.
9996 */
100- static void sliceMatchedPairChildren (
97+ void sliceMatchedPairChildren (
10198 const ShadowViewNodePair& oldPair,
10299 const ShadowViewNodePair& newPair,
103100 ViewNodePairScope& scope,
@@ -148,7 +145,7 @@ static_assert(
148145 std::is_move_assignable<ShadowViewNodePair>::value,
149146 " `ShadowViewNodePair` must be `move assignable`." );
150147
151- static void calculateShadowViewMutations (
148+ void calculateShadowViewMutations (
152149 ViewNodePairScope& scope,
153150 ShadowViewMutation::List& mutations,
154151 Tag parentTag,
@@ -157,8 +154,6 @@ static void calculateShadowViewMutations(
157154 const CullingContext& oldCullingContext = {},
158155 const CullingContext& newCullingContext = {});
159156
160- namespace {
161-
162157struct OrderedMutationInstructionContainer {
163158 ShadowViewMutation::List createMutations{};
164159 ShadowViewMutation::List deleteMutations{};
@@ -169,28 +164,7 @@ struct OrderedMutationInstructionContainer {
169164 ShadowViewMutation::List destructiveDownwardMutations{};
170165};
171166
172- } // namespace
173-
174- static void updateMatchedPairSubtrees (
175- ViewNodePairScope& scope,
176- OrderedMutationInstructionContainer& mutationContainer,
177- std::unordered_map<Tag, ShadowViewNodePair*>& newRemainingPairs,
178- std::vector<ShadowViewNodePair*>& oldChildPairs,
179- Tag parentTag,
180- const ShadowViewNodePair& oldPair,
181- const ShadowViewNodePair& newPair,
182- const CullingContext& oldCullingContext,
183- const CullingContext& newCullingContext);
184-
185- static void updateMatchedPair (
186- OrderedMutationInstructionContainer& mutationContainer,
187- bool oldNodeFoundInOrder,
188- bool newNodeFoundInOrder,
189- Tag parentTag,
190- const ShadowViewNodePair& oldPair,
191- const ShadowViewNodePair& newPair);
192-
193- static void calculateShadowViewMutationsFlattener (
167+ void calculateShadowViewMutationsFlattener (
194168 ViewNodePairScope& scope,
195169 ReparentMode reparentMode,
196170 OrderedMutationInstructionContainer& mutationContainer,
@@ -211,7 +185,7 @@ static void calculateShadowViewMutationsFlattener(
211185 * specifically `newRemainingPairs`, and so the caller must also own
212186 * the ViewNodePairScope used within.
213187 */
214- static void updateMatchedPairSubtrees (
188+ void updateMatchedPairSubtrees (
215189 ViewNodePairScope& scope,
216190 OrderedMutationInstructionContainer& mutationContainer,
217191 std::unordered_map<Tag, ShadowViewNodePair*>& newRemainingPairs,
@@ -362,7 +336,7 @@ static void updateMatchedPairSubtrees(
362336 * or INSERTTed when they are encountered via in-order-traversal, to ensure
363337 * correct ordering of INSERT and REMOVE mutations.
364338 */
365- static void updateMatchedPair (
339+ void updateMatchedPair (
366340 OrderedMutationInstructionContainer& mutationContainer,
367341 bool oldNodeFoundInOrder,
368342 bool newNodeFoundInOrder,
@@ -455,7 +429,7 @@ static void updateMatchedPair(
455429 * @param parentTagForUpdate current parent in which node is mounted,
456430 * used for update mutations
457431 */
458- static void calculateShadowViewMutationsFlattener (
432+ void calculateShadowViewMutationsFlattener (
459433 ViewNodePairScope& scope,
460434 ReparentMode reparentMode,
461435 OrderedMutationInstructionContainer& mutationContainer,
@@ -497,10 +471,8 @@ static void calculateShadowViewMutationsFlattener(
497471 deletionCreationCandidatePairs;
498472 deletionCreationCandidatePairs.reserve (treeChildren.size ());
499473
500- for (size_t index = 0 ;
501- index < treeChildren.size () && index < treeChildren.size ();
502- index++) {
503- auto & treeChildPair = *treeChildren[index];
474+ for (auto * treeChildPairPtr : treeChildren) {
475+ auto & treeChildPair = *treeChildPairPtr;
504476
505477 // Try to find node in other tree
506478 auto unvisitedIt = unvisitedOtherNodes.find (treeChildPair.shadowView .tag );
@@ -913,7 +885,7 @@ static void calculateShadowViewMutationsFlattener(
913885 }
914886}
915887
916- static void calculateShadowViewMutations (
888+ void calculateShadowViewMutations (
917889 ViewNodePairScope& scope,
918890 ShadowViewMutation::List& mutations,
919891 Tag parentTag,
@@ -1400,6 +1372,8 @@ static void calculateShadowViewMutations(
14001372 std::back_inserter (mutations));
14011373}
14021374
1375+ } // namespace
1376+
14031377ShadowViewMutation::List calculateShadowViewMutations (
14041378 const ShadowNode& oldRootShadowNode,
14051379 const ShadowNode& newRootShadowNode) {
0 commit comments