From 1d4e7f6d40732c0ee430671799267a27424a6048 Mon Sep 17 00:00:00 2001 From: Andrei Shikov Date: Thu, 9 Dec 2021 09:45:50 -0800 Subject: [PATCH] Use reference for command args Summary: The IDE warning suggests that passing folly::dynamic by value will create a copy on each call. Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D32978154 fbshipit-source-id: a47a60c332a9d299eb2110d3537dfab0bc2398b6 --- React/Fabric/RCTScheduler.h | 2 +- React/Fabric/RCTScheduler.mm | 2 +- React/Fabric/RCTSurfacePresenter.mm | 2 +- .../src/main/java/com/facebook/react/fabric/jni/Binding.cpp | 2 +- .../src/main/java/com/facebook/react/fabric/jni/Binding.h | 2 +- ReactCommon/react/renderer/scheduler/Scheduler.cpp | 2 +- ReactCommon/react/renderer/scheduler/Scheduler.h | 2 +- ReactCommon/react/renderer/scheduler/SchedulerDelegate.h | 2 +- ReactCommon/react/renderer/uimanager/UIManager.cpp | 2 +- ReactCommon/react/renderer/uimanager/UIManager.h | 2 +- ReactCommon/react/renderer/uimanager/UIManagerDelegate.h | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/React/Fabric/RCTScheduler.h b/React/Fabric/RCTScheduler.h index 68353bfea68d8b..525e3b5b50bad2 100644 --- a/React/Fabric/RCTScheduler.h +++ b/React/Fabric/RCTScheduler.h @@ -30,7 +30,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)schedulerDidDispatchCommand:(facebook::react::ShadowView const &)shadowView commandName:(std::string const &)commandName - args:(folly::dynamic const)args; + args:(folly::dynamic const &)args; - (void)schedulerDidSendAccessibilityEvent:(facebook::react::ShadowView const &)shadowView eventType:(std::string const &)eventType; diff --git a/React/Fabric/RCTScheduler.mm b/React/Fabric/RCTScheduler.mm index ce477e90c82128..566cd886df8129 100644 --- a/React/Fabric/RCTScheduler.mm +++ b/React/Fabric/RCTScheduler.mm @@ -48,7 +48,7 @@ void schedulerDidCloneShadowNode( void schedulerDidDispatchCommand( const ShadowView &shadowView, const std::string &commandName, - const folly::dynamic args) override + const folly::dynamic &args) override { RCTScheduler *scheduler = (__bridge RCTScheduler *)scheduler_; [scheduler.delegate schedulerDidDispatchCommand:shadowView commandName:commandName args:args]; diff --git a/React/Fabric/RCTSurfacePresenter.mm b/React/Fabric/RCTSurfacePresenter.mm index 81ec1d5cca168a..839270fabccd72 100644 --- a/React/Fabric/RCTSurfacePresenter.mm +++ b/React/Fabric/RCTSurfacePresenter.mm @@ -336,7 +336,7 @@ - (void)schedulerDidFinishTransaction:(MountingCoordinator::Shared const &)mount - (void)schedulerDidDispatchCommand:(ShadowView const &)shadowView commandName:(std::string const &)commandName - args:(folly::dynamic const)args + args:(folly::dynamic const &)args { ReactTag tag = shadowView.tag; NSString *commandStr = [[NSString alloc] initWithUTF8String:commandName.c_str()]; diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp index 2871394179bb69..9f68687b4ad02d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp @@ -1295,7 +1295,7 @@ void Binding::schedulerDidCloneShadowNode( void Binding::schedulerDidDispatchCommand( const ShadowView &shadowView, std::string const &commandName, - folly::dynamic const args) { + folly::dynamic const &args) { jni::global_ref localJavaUIManager = getJavaUIManager(); if (!localJavaUIManager) { LOG(ERROR) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h index b1d646e11eecc0..d022af57a3f4fb 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h @@ -156,7 +156,7 @@ class Binding : public jni::HybridClass, void schedulerDidDispatchCommand( const ShadowView &shadowView, std::string const &commandName, - folly::dynamic const args) override; + folly::dynamic const &args) override; void schedulerDidSendAccessibilityEvent( const ShadowView &shadowView, diff --git a/ReactCommon/react/renderer/scheduler/Scheduler.cpp b/ReactCommon/react/renderer/scheduler/Scheduler.cpp index 5da3c21d4c2b43..dd01cbe995cb0f 100644 --- a/ReactCommon/react/renderer/scheduler/Scheduler.cpp +++ b/ReactCommon/react/renderer/scheduler/Scheduler.cpp @@ -315,7 +315,7 @@ void Scheduler::uiManagerDidCloneShadowNode( void Scheduler::uiManagerDidDispatchCommand( const ShadowNode::Shared &shadowNode, std::string const &commandName, - folly::dynamic const args) { + folly::dynamic const &args) { SystraceSection s("Scheduler::uiManagerDispatchCommand"); if (delegate_) { diff --git a/ReactCommon/react/renderer/scheduler/Scheduler.h b/ReactCommon/react/renderer/scheduler/Scheduler.h index 32beafc7e9ffda..33de61fbe138e8 100644 --- a/ReactCommon/react/renderer/scheduler/Scheduler.h +++ b/ReactCommon/react/renderer/scheduler/Scheduler.h @@ -95,7 +95,7 @@ class Scheduler final : public UIManagerDelegate { void uiManagerDidDispatchCommand( const ShadowNode::Shared &shadowNode, std::string const &commandName, - folly::dynamic const args) override; + folly::dynamic const &args) override; void uiManagerDidSendAccessibilityEvent( const ShadowNode::Shared &shadowNode, std::string const &eventType) override; diff --git a/ReactCommon/react/renderer/scheduler/SchedulerDelegate.h b/ReactCommon/react/renderer/scheduler/SchedulerDelegate.h index cfd41c5d30d189..87ae0f06414a3c 100644 --- a/ReactCommon/react/renderer/scheduler/SchedulerDelegate.h +++ b/ReactCommon/react/renderer/scheduler/SchedulerDelegate.h @@ -47,7 +47,7 @@ class SchedulerDelegate { virtual void schedulerDidDispatchCommand( const ShadowView &shadowView, std::string const &commandName, - folly::dynamic const args) = 0; + folly::dynamic const &args) = 0; virtual void schedulerDidSendAccessibilityEvent( const ShadowView &shadowView, diff --git a/ReactCommon/react/renderer/uimanager/UIManager.cpp b/ReactCommon/react/renderer/uimanager/UIManager.cpp index 3ff165dd5f42f2..eaa90ca3b084a8 100644 --- a/ReactCommon/react/renderer/uimanager/UIManager.cpp +++ b/ReactCommon/react/renderer/uimanager/UIManager.cpp @@ -333,7 +333,7 @@ void UIManager::updateState(StateUpdate const &stateUpdate) const { void UIManager::dispatchCommand( const ShadowNode::Shared &shadowNode, std::string const &commandName, - folly::dynamic const args) const { + folly::dynamic const &args) const { if (delegate_) { delegate_->uiManagerDidDispatchCommand(shadowNode, commandName, args); } diff --git a/ReactCommon/react/renderer/uimanager/UIManager.h b/ReactCommon/react/renderer/uimanager/UIManager.h index f5c8f0c21c79fd..983153d7e85c82 100644 --- a/ReactCommon/react/renderer/uimanager/UIManager.h +++ b/ReactCommon/react/renderer/uimanager/UIManager.h @@ -167,7 +167,7 @@ class UIManager final : public ShadowTreeDelegate { void dispatchCommand( const ShadowNode::Shared &shadowNode, std::string const &commandName, - folly::dynamic const args) const; + folly::dynamic const &args) const; void sendAccessibilityEvent( const ShadowNode::Shared &shadowNode, diff --git a/ReactCommon/react/renderer/uimanager/UIManagerDelegate.h b/ReactCommon/react/renderer/uimanager/UIManagerDelegate.h index 91d8bf55107423..074f958ef13d4b 100644 --- a/ReactCommon/react/renderer/uimanager/UIManagerDelegate.h +++ b/ReactCommon/react/renderer/uimanager/UIManagerDelegate.h @@ -47,7 +47,7 @@ class UIManagerDelegate { virtual void uiManagerDidDispatchCommand( const ShadowNode::Shared &shadowNode, std::string const &commandName, - folly::dynamic const args) = 0; + folly::dynamic const &args) = 0; /* * Called when UIManager wants to dispatch some accessibility event