diff --git a/ReactCommon/fabric/uimanager/Scheduler.cpp b/ReactCommon/fabric/uimanager/Scheduler.cpp index c2dada719..c5bfe9193 100644 --- a/ReactCommon/fabric/uimanager/Scheduler.cpp +++ b/ReactCommon/fabric/uimanager/Scheduler.cpp @@ -45,9 +45,9 @@ Scheduler::~Scheduler() { } void Scheduler::registerRootTag(Tag rootTag) { - const auto &shadowTree = std::make_shared(rootTag); + auto shadowTree = std::make_unique(rootTag); shadowTree->setDelegate(this); - shadowTreeRegistry_.insert({rootTag, shadowTree}); + shadowTreeRegistry_.emplace(rootTag, std::move(shadowTree)); } void Scheduler::unregisterRootTag(Tag rootTag) { @@ -82,9 +82,9 @@ SchedulerDelegate *Scheduler::getDelegate() const { #pragma mark - ShadowTreeDelegate -void Scheduler::shadowTreeDidCommit(const SharedShadowTree &shadowTree, const ShadowViewMutationList &mutations) { +void Scheduler::shadowTreeDidCommit(const ShadowTree &shadowTree, const ShadowViewMutationList &mutations) { if (delegate_) { - delegate_->schedulerDidFinishTransaction(shadowTree->getRootTag(), mutations); + delegate_->schedulerDidFinishTransaction(shadowTree.getRootTag(), mutations); } } diff --git a/ReactCommon/fabric/uimanager/Scheduler.h b/ReactCommon/fabric/uimanager/Scheduler.h index 16c164867..795803349 100644 --- a/ReactCommon/fabric/uimanager/Scheduler.h +++ b/ReactCommon/fabric/uimanager/Scheduler.h @@ -57,7 +57,7 @@ public: #pragma mark - ShadowTreeDelegate - void shadowTreeDidCommit(const SharedShadowTree &shadowTree, const ShadowViewMutationList &mutations) override; + void shadowTreeDidCommit(const ShadowTree &shadowTree, const ShadowViewMutationList &mutations) override; #pragma mark - Deprecated @@ -69,7 +69,7 @@ public: private: SchedulerDelegate *delegate_; std::shared_ptr uiManager_; - std::unordered_map shadowTreeRegistry_; + std::unordered_map> shadowTreeRegistry_; SharedEventDispatcher eventDispatcher_; SharedContextContainer contextContainer_; }; diff --git a/ReactCommon/fabric/uimanager/ShadowTree.cpp b/ReactCommon/fabric/uimanager/ShadowTree.cpp index 7edb570ae..1460620d4 100644 --- a/ReactCommon/fabric/uimanager/ShadowTree.cpp +++ b/ReactCommon/fabric/uimanager/ShadowTree.cpp @@ -87,7 +87,7 @@ void ShadowTree::complete(UnsharedRootShadowNode newRootShadowNode) { emitLayoutEvents(mutations); if (delegate_) { - delegate_->shadowTreeDidCommit(shared_from_this(), mutations); + delegate_->shadowTreeDidCommit(*this, mutations); } } } diff --git a/ReactCommon/fabric/uimanager/ShadowTree.h b/ReactCommon/fabric/uimanager/ShadowTree.h index 0c6f08942..8a91f49e3 100644 --- a/ReactCommon/fabric/uimanager/ShadowTree.h +++ b/ReactCommon/fabric/uimanager/ShadowTree.h @@ -18,15 +18,10 @@ namespace facebook { namespace react { -class ShadowTree; - -using SharedShadowTree = std::shared_ptr; - /* * Represents the shadow tree and its lifecycle. */ -class ShadowTree final: - public std::enable_shared_from_this { +class ShadowTree final { public: diff --git a/ReactCommon/fabric/uimanager/ShadowTreeDelegate.h b/ReactCommon/fabric/uimanager/ShadowTreeDelegate.h index 580a8a9fb..386bdd648 100644 --- a/ReactCommon/fabric/uimanager/ShadowTreeDelegate.h +++ b/ReactCommon/fabric/uimanager/ShadowTreeDelegate.h @@ -21,7 +21,7 @@ public: /* * Called right after Shadow Tree commit a new state of the the tree. */ - virtual void shadowTreeDidCommit(const std::shared_ptr &shadowTree, const ShadowViewMutationList &mutations) = 0; + virtual void shadowTreeDidCommit(const ShadowTree &shadowTree, const ShadowViewMutationList &mutations) = 0; }; } // namespace react