mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
simplify parent-child flattening-unflattening (#50893)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/50893 changelog: [internal] In the two branches changed by this diff, it is unnecessary to check `reparentMode` because `reparentMode` and `childReparentMode` will always mismatch. When `childReparentMode` is unflatten, `reparentMode` will be flatten and vice versa. This is guaranteed by a `if else` statement above: https://github.com/facebook/react-native/blob/main/packages/react-native/ReactCommon/react/renderer/mounting/Differentiator.cpp#L674 This slightly simplifies code and lowers the burden on the reader. Reviewed By: javache, rubennorte Differential Revision: D73571160 fbshipit-source-id: 8623d991f7b063f70c95720ca0d3b63318dfc08b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
94fed5facc
commit
d8fe0d2ee2
@@ -699,9 +699,10 @@ static void calculateShadowViewMutationsFlattener(
|
||||
}
|
||||
}
|
||||
|
||||
// Unflatten parent, flatten child
|
||||
if (childReparentMode == ReparentMode::Flatten) {
|
||||
auto parentTagForUpdateWhenUnflattened =
|
||||
// Unflatten parent, flatten child
|
||||
react_native_assert(reparentMode == ReparentMode::Unflatten);
|
||||
auto fixedParentTagForUpdate =
|
||||
ReactNativeFeatureFlags::
|
||||
enableFixForParentTagDuringReparenting()
|
||||
? newTreeNodePair.shadowView.tag
|
||||
@@ -715,22 +716,18 @@ static void calculateShadowViewMutationsFlattener(
|
||||
scope,
|
||||
ReparentMode::Flatten,
|
||||
mutationContainer,
|
||||
(reparentMode == ReparentMode::Flatten
|
||||
? parentTag
|
||||
: newTreeNodePair.shadowView.tag),
|
||||
newTreeNodePair.shadowView.tag,
|
||||
unvisitedRecursiveChildPairs,
|
||||
oldTreeNodePair,
|
||||
(reparentMode == ReparentMode::Flatten
|
||||
? oldTreeNodePair.shadowView.tag
|
||||
: parentTagForUpdateWhenUnflattened),
|
||||
fixedParentTagForUpdate,
|
||||
subVisitedNewMap,
|
||||
subVisitedOldMap,
|
||||
cullingContext.adjustCullingContextIfNeeded(oldTreeNodePair));
|
||||
}
|
||||
// Flatten parent, unflatten child
|
||||
else {
|
||||
adjustedNewCullingContext);
|
||||
} else {
|
||||
// Flatten parent, unflatten child
|
||||
react_native_assert(reparentMode == ReparentMode::Flatten);
|
||||
// Unflatten old list into new tree
|
||||
auto parentTagForUpdateWhenFlattened =
|
||||
auto fixedParentTagForUpdate =
|
||||
ReactNativeFeatureFlags::
|
||||
enableFixForParentTagDuringReparenting()
|
||||
? parentTagForUpdate
|
||||
@@ -739,21 +736,13 @@ static void calculateShadowViewMutationsFlattener(
|
||||
scope,
|
||||
/* reparentMode */ ReparentMode::Unflatten,
|
||||
mutationContainer,
|
||||
/* parentTag */
|
||||
(reparentMode == ReparentMode::Flatten
|
||||
? parentTag
|
||||
: newTreeNodePair.shadowView.tag),
|
||||
parentTag,
|
||||
/* unvisitedOtherNodes */ unvisitedRecursiveChildPairs,
|
||||
/* node */ newTreeNodePair,
|
||||
/* parentTagForUpdate */
|
||||
(reparentMode == ReparentMode::Flatten
|
||||
? parentTagForUpdateWhenFlattened
|
||||
: parentTag),
|
||||
/* parentTagForUpdate */ fixedParentTagForUpdate,
|
||||
/* parentSubVisitedOtherNewNodes */ subVisitedNewMap,
|
||||
/* parentSubVisitedOtherOldNodes */ subVisitedOldMap,
|
||||
reparentMode == ReparentMode::Flatten
|
||||
? adjustedOldCullingContext
|
||||
: adjustedNewCullingContext);
|
||||
/* cullingContext */ adjustedOldCullingContext);
|
||||
|
||||
// If old nodes were not visited, we know that we can delete them
|
||||
// now. They will be removed from the hierarchy by the outermost
|
||||
|
||||
Reference in New Issue
Block a user