From cf428bde1ce98495dca2d2e4e8793664f6123260 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Fri, 9 May 2025 08:36:44 -0700 Subject: [PATCH] Simplify StubViewTree creation (#51221) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/51221 In the case of an empty root node, we don't need `buildStubViewTreeWithoutUsingDifferentiator` to create the initial `StubViewTree` When testing with Fantom, this caused an additional unnecessary clone of RootShadowNode. Changelog: [Internal] Reviewed By: lenaic Differential Revision: D74472766 fbshipit-source-id: 076e859a6c5795e9026c7a5f8246a5658db4a94b --- .../react/renderer/animations/tests/LayoutAnimationTest.cpp | 2 +- .../react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp b/packages/react-native/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp index 36ae2687edd..e9f1b905c72 100644 --- a/packages/react-native/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp @@ -121,7 +121,7 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations( ShadowNode::ListOfShared{singleRootChildNode})})); // Building an initial view hierarchy. - auto viewTree = buildStubViewTreeWithoutUsingDifferentiator(*emptyRootNode); + auto viewTree = StubViewTree(ShadowView(*emptyRootNode)); viewTree.mutate( calculateShadowViewMutations(*emptyRootNode, *currentRootNode)); diff --git a/packages/react-native/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp b/packages/react-native/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp index 6b75117b89c..086fe3459e2 100644 --- a/packages/react-native/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp @@ -80,7 +80,7 @@ static void testShadowNodeTreeLifeCycle( ShadowNode::ListOfShared{singleRootChildNode})})); // Building an initial view hierarchy. - auto viewTree = buildStubViewTreeWithoutUsingDifferentiator(*emptyRootNode); + auto viewTree = StubViewTree(ShadowView(*emptyRootNode)); viewTree.mutate( calculateShadowViewMutations(*emptyRootNode, *currentRootNode));