From e2028a8cb836d1a9f05ed3dacd3d082ae5b6040c Mon Sep 17 00:00:00 2001 From: Paige Sun Date: Wed, 14 Sep 2022 14:51:27 -0700 Subject: [PATCH] Remove unused RuntimeExecutor from UIManagerBinding constructor Summary: Changelog: [Internal] Remove unused RuntimeExecutor from UIManagerBinding constructor Since [UIManager is the class that has a reference to RuntimeExecutor](https://github.com/facebook/react-native/blob/ce50c43986bae05ad62552be46f4d5bb4a46f097/ReactCommon/react/renderer/uimanager/UIManager.h#L35-L36), there's no reason for `UIManagerBinding` to own a reference to RuntimeExecutor too. The purpose of `UIManagerBinding` is to bind the Fabric `std::shared_ptr` in C++ to `global.nativeFabricUIManager` in JS. Doing this cleanup to make the next diff easier. Reviewed By: sammy-SC Differential Revision: D39490927 fbshipit-source-id: 4c393dccc6985bef44e3b0afc32b9f79bea25f80 --- ReactCommon/react/renderer/scheduler/Scheduler.cpp | 8 +++----- .../react/renderer/uimanager/UIManagerBinding.cpp | 11 +++-------- .../react/renderer/uimanager/UIManagerBinding.h | 8 +------- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/ReactCommon/react/renderer/scheduler/Scheduler.cpp b/ReactCommon/react/renderer/scheduler/Scheduler.cpp index a8418c52c6e..89fd0a5fb73 100644 --- a/ReactCommon/react/renderer/scheduler/Scheduler.cpp +++ b/ReactCommon/react/renderer/scheduler/Scheduler.cpp @@ -95,11 +95,9 @@ Scheduler::Scheduler( uiManager->setDelegate(this); uiManager->setComponentDescriptorRegistry(componentDescriptorRegistry_); - runtimeExecutor_( - [uiManager, runtimeExecutor = runtimeExecutor_](jsi::Runtime &runtime) { - UIManagerBinding::createAndInstallIfNeeded( - runtime, runtimeExecutor, uiManager); - }); + runtimeExecutor_([uiManager](jsi::Runtime &runtime) { + UIManagerBinding::createAndInstallIfNeeded(runtime, uiManager); + }); auto componentDescriptorRegistryKey = "ComponentDescriptorRegistry_DO_NOT_USE_PRETTY_PLEASE"; diff --git a/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp b/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp index e1ac1399850..c8af3e88232 100644 --- a/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp +++ b/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp @@ -23,7 +23,6 @@ namespace facebook::react { void UIManagerBinding::createAndInstallIfNeeded( jsi::Runtime &runtime, - RuntimeExecutor const &runtimeExecutor, std::shared_ptr const &uiManager) { auto uiManagerModuleName = "nativeFabricUIManager"; @@ -32,8 +31,7 @@ void UIManagerBinding::createAndInstallIfNeeded( if (uiManagerValue.isUndefined()) { // The global namespace does not have an instance of the binding; // we need to create, install and return it. - auto uiManagerBinding = - std::make_shared(uiManager, runtimeExecutor); + auto uiManagerBinding = std::make_shared(uiManager); auto object = jsi::Object::createFromHostObject(runtime, uiManagerBinding); runtime.global().setProperty( runtime, uiManagerModuleName, std::move(object)); @@ -54,11 +52,8 @@ std::shared_ptr UIManagerBinding::getBinding( return uiManagerObject.getHostObject(runtime); } -UIManagerBinding::UIManagerBinding( - std::shared_ptr uiManager, - RuntimeExecutor runtimeExecutor) - : uiManager_(std::move(uiManager)), - runtimeExecutor_(std::move(runtimeExecutor)) {} +UIManagerBinding::UIManagerBinding(std::shared_ptr uiManager) + : uiManager_(std::move(uiManager)) {} UIManagerBinding::~UIManagerBinding() { LOG(WARNING) << "UIManagerBinding::~UIManagerBinding() was called (address: " diff --git a/ReactCommon/react/renderer/uimanager/UIManagerBinding.h b/ReactCommon/react/renderer/uimanager/UIManagerBinding.h index 9ddd53d77e2..f929ba54760 100644 --- a/ReactCommon/react/renderer/uimanager/UIManagerBinding.h +++ b/ReactCommon/react/renderer/uimanager/UIManagerBinding.h @@ -7,7 +7,6 @@ #pragma once -#include #include #include #include @@ -28,7 +27,6 @@ class UIManagerBinding : public jsi::HostObject { */ static void createAndInstallIfNeeded( jsi::Runtime &runtime, - RuntimeExecutor const &runtimeExecutor, std::shared_ptr const &uiManager); /* @@ -37,9 +35,7 @@ class UIManagerBinding : public jsi::HostObject { */ static std::shared_ptr getBinding(jsi::Runtime &runtime); - UIManagerBinding( - std::shared_ptr uiManager, - RuntimeExecutor runtimeExecutor); + UIManagerBinding(std::shared_ptr uiManager); ~UIManagerBinding(); @@ -76,8 +72,6 @@ class UIManagerBinding : public jsi::HostObject { std::shared_ptr uiManager_; std::unique_ptr eventHandler_; mutable ReactEventPriority currentEventPriority_; - - RuntimeExecutor runtimeExecutor_; }; } // namespace facebook::react