Pass MountingCoordinator by value instead of reference

Summary:
changelog: [internal]

Passing MountingCoordinator argument by value instead of reference. Using reference does not make sense since we eventually take ownership of shared_ptr anyway. This better communicates the intent.

Reviewed By: christophpurrer

Differential Revision: D43082955

fbshipit-source-id: 29e20abb9824c10a5f0d5e0ba1049ff6d67cee98
This commit is contained in:
Samuel Susla
2023-02-08 15:48:17 -08:00
committed by Facebook GitHub Bot
parent bc766ec7f8
commit 2e3f55aced
16 changed files with 24 additions and 29 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ NS_ASSUME_NONNULL_BEGIN
* Schedule a mounting transaction to be performed on the main thread.
* Can be called from any thread.
*/
- (void)scheduleTransaction:(facebook::react::MountingCoordinator::Shared const &)mountingCoordinator;
- (void)scheduleTransaction:(facebook::react::MountingCoordinator::Shared)mountingCoordinator;
/**
* Dispatch a command to be performed on the main thread.
+4 -5
View File
@@ -196,21 +196,20 @@ static void RCTPerformMountInstructions(
componentViewDescriptor:rootViewDescriptor];
}
- (void)scheduleTransaction:(MountingCoordinator::Shared const &)mountingCoordinator
- (void)scheduleTransaction:(MountingCoordinator::Shared)mountingCoordinator
{
if (RCTIsMainQueue()) {
// Already on the proper thread, so:
// * No need to do a thread jump;
// * No need to do expensive copy of all mutations;
// * No need to allocate a block.
[self initiateTransaction:mountingCoordinator];
[self initiateTransaction:std::move(mountingCoordinator)];
return;
}
auto mountingCoordinatorCopy = mountingCoordinator;
RCTExecuteOnMainQueue(^{
RCTAssertMainQueue();
[self initiateTransaction:mountingCoordinatorCopy];
[self initiateTransaction:std::move(mountingCoordinator)];
});
}
@@ -244,7 +243,7 @@ static void RCTPerformMountInstructions(
});
}
- (void)initiateTransaction:(MountingCoordinator::Shared const &)mountingCoordinator
- (void)initiateTransaction:(MountingCoordinator::Shared)mountingCoordinator
{
SystraceSection s("-[RCTMountingManager initiateTransaction:]");
RCTAssertMainQueue();
+2 -2
View File
@@ -24,10 +24,10 @@ class SchedulerDelegateProxy : public SchedulerDelegate {
public:
SchedulerDelegateProxy(void *scheduler) : scheduler_(scheduler) {}
void schedulerDidFinishTransaction(MountingCoordinator::Shared const &mountingCoordinator) override
void schedulerDidFinishTransaction(MountingCoordinator::Shared mountingCoordinator) override
{
RCTScheduler *scheduler = (__bridge RCTScheduler *)scheduler_;
[scheduler.delegate schedulerDidFinishTransaction:mountingCoordinator];
[scheduler.delegate schedulerDidFinishTransaction:std::move(mountingCoordinator)];
}
void schedulerDidRequestPreliminaryViewAllocation(SurfaceId surfaceId, const ShadowNode &shadowNode) override
@@ -484,14 +484,14 @@ std::shared_ptr<FabricMountingManager> Binding::verifyMountingManager(
}
void Binding::schedulerDidFinishTransaction(
MountingCoordinator::Shared const &mountingCoordinator) {
MountingCoordinator::Shared mountingCoordinator) {
auto mountingManager =
verifyMountingManager("Binding::schedulerDidFinishTransaction");
if (!mountingManager) {
return;
}
mountingManager->executeMount(mountingCoordinator);
mountingManager->executeMount(std::move(mountingCoordinator));
}
void Binding::schedulerDidRequestPreliminaryViewAllocation(
@@ -94,7 +94,7 @@ class Binding : public jni::HybridClass<Binding>,
void unregisterSurface(SurfaceHandlerBinding *surfaceHandler);
void schedulerDidFinishTransaction(
MountingCoordinator::Shared const &mountingCoordinator) override;
MountingCoordinator::Shared mountingCoordinator) override;
void schedulerDidRequestPreliminaryViewAllocation(
const SurfaceId surfaceId,
@@ -263,7 +263,7 @@ local_ref<jobject> FabricMountingManager::getProps(
}
void FabricMountingManager::executeMount(
MountingCoordinator::Shared const &mountingCoordinator) {
MountingCoordinator::Shared mountingCoordinator) {
std::lock_guard<std::recursive_mutex> lock(commitMutex_);
SystraceSection s(
@@ -41,7 +41,7 @@ class FabricMountingManager final {
void preallocateShadowView(SurfaceId surfaceId, ShadowView const &shadowView);
void executeMount(MountingCoordinator::Shared const &mountingCoordinator);
void executeMount(MountingCoordinator::Shared mountingCoordinator);
void dispatchCommand(
ShadowView const &shadowView,
@@ -415,7 +415,7 @@ ShadowTreeRevision ShadowTree::getCurrentRevision() const {
void ShadowTree::mount(ShadowTreeRevision const &revision) const {
mountingCoordinator_->push(revision);
delegate_.shadowTreeDidFinishTransaction(*this, mountingCoordinator_);
delegate_.shadowTreeDidFinishTransaction(mountingCoordinator_);
}
void ShadowTree::commitEmptyTree() const {
@@ -458,7 +458,7 @@ void ShadowTree::emitLayoutEvents(
}
void ShadowTree::notifyDelegatesOfUpdates() const {
delegate_.shadowTreeDidFinishTransaction(*this, mountingCoordinator_);
delegate_.shadowTreeDidFinishTransaction(mountingCoordinator_);
}
} // namespace facebook::react
@@ -34,8 +34,7 @@ class ShadowTreeDelegate {
* Called right after Shadow Tree commit a new state of the tree.
*/
virtual void shadowTreeDidFinishTransaction(
ShadowTree const &shadowTree,
MountingCoordinator::Shared const &mountingCoordinator) const = 0;
MountingCoordinator::Shared mountingCoordinator) const = 0;
virtual ~ShadowTreeDelegate() noexcept = default;
};
@@ -32,8 +32,7 @@ class DummyShadowTreeDelegate : public ShadowTreeDelegate {
};
void shadowTreeDidFinishTransaction(
ShadowTree const &shadowTree,
MountingCoordinator::Shared const &mountingCoordinator) const override{};
MountingCoordinator::Shared mountingCoordinator) const override{};
};
inline ShadowNode const *findDescendantNode(
@@ -299,11 +299,11 @@ void Scheduler::animationTick() const {
#pragma mark - UIManagerDelegate
void Scheduler::uiManagerDidFinishTransaction(
MountingCoordinator::Shared const &mountingCoordinator) {
MountingCoordinator::Shared mountingCoordinator) {
SystraceSection s("Scheduler::uiManagerDidFinishTransaction");
if (delegate_ != nullptr) {
delegate_->schedulerDidFinishTransaction(mountingCoordinator);
delegate_->schedulerDidFinishTransaction(std::move(mountingCoordinator));
}
}
void Scheduler::uiManagerDidCreateShadowNode(const ShadowNode &shadowNode) {
@@ -88,7 +88,7 @@ class Scheduler final : public UIManagerDelegate {
#pragma mark - UIManagerDelegate
void uiManagerDidFinishTransaction(
MountingCoordinator::Shared const &mountingCoordinator) override;
MountingCoordinator::Shared mountingCoordinator) override;
void uiManagerDidCreateShadowNode(const ShadowNode &shadowNode) override;
void uiManagerDidDispatchCommand(
const ShadowNode::Shared &shadowNode,
@@ -26,7 +26,7 @@ class SchedulerDelegate {
* to construct a new one.
*/
virtual void schedulerDidFinishTransaction(
MountingCoordinator::Shared const &mountingCoordinator) = 0;
MountingCoordinator::Shared mountingCoordinator) = 0;
/*
* Called right after a new ShadowNode was created.
@@ -532,12 +532,11 @@ RootShadowNode::Unshared UIManager::shadowTreeWillCommit(
}
void UIManager::shadowTreeDidFinishTransaction(
ShadowTree const & /*shadowTree*/,
MountingCoordinator::Shared const &mountingCoordinator) const {
MountingCoordinator::Shared mountingCoordinator) const {
SystraceSection s("UIManager::shadowTreeDidFinishTransaction");
if (delegate_ != nullptr) {
delegate_->uiManagerDidFinishTransaction(mountingCoordinator);
delegate_->uiManagerDidFinishTransaction(std::move(mountingCoordinator));
}
}
@@ -103,8 +103,7 @@ class UIManager final : public ShadowTreeDelegate {
#pragma mark - ShadowTreeDelegate
void shadowTreeDidFinishTransaction(
ShadowTree const &shadowTree,
MountingCoordinator::Shared const &mountingCoordinator) const override;
MountingCoordinator::Shared mountingCoordinator) const override;
RootShadowNode::Unshared shadowTreeWillCommit(
ShadowTree const &shadowTree,
@@ -23,7 +23,7 @@ class UIManagerDelegate {
* For this moment the tree is already laid out and sealed.
*/
virtual void uiManagerDidFinishTransaction(
MountingCoordinator::Shared const &mountingCoordinator) = 0;
MountingCoordinator::Shared mountingCoordinator) = 0;
/*
* Called each time when UIManager constructs a new Shadow Node. Receiver