Skip to content

Commit 9ef3045

Browse files
janicduplessisfacebook-github-bot
authored andcommitted
Pass string by ref in TurboModule template (facebook#33970)
Summary: facebook@3337add made some changes to method signature but the template wasn't updated. This adds the missing changes. ## Changelog [Internal] [Fixed] - Pass string by ref in TurboModule template Pull Request resolved: facebook#33970 Test Plan: Didn't test the template directly, but the change is trivial. Reviewed By: cortinico Differential Revision: D36964481 Pulled By: dmitryrykun fbshipit-source-id: 561e32f218baf398b8d4d8c77381a2642e22ef42
1 parent f296e0e commit 9ef3045

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

template/android/app/src/main/jni/MainApplicationModuleProvider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace facebook {
66
namespace react {
77

88
std::shared_ptr<TurboModule> MainApplicationModuleProvider(
9-
const std::string moduleName,
9+
const std::string &moduleName,
1010
const JavaTurboModule::InitParams &params) {
1111
// Here you can provide your own module provider for TurboModules coming from
1212
// either your application or from external libraries. The approach to follow

template/android/app/src/main/jni/MainApplicationModuleProvider.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace facebook {
99
namespace react {
1010

1111
std::shared_ptr<TurboModule> MainApplicationModuleProvider(
12-
const std::string moduleName,
12+
const std::string &moduleName,
1313
const JavaTurboModule::InitParams &params);
1414

1515
} // namespace react

template/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ void MainApplicationTurboModuleManagerDelegate::registerNatives() {
2222

2323
std::shared_ptr<TurboModule>
2424
MainApplicationTurboModuleManagerDelegate::getTurboModule(
25-
const std::string name,
26-
const std::shared_ptr<CallInvoker> jsInvoker) {
25+
const std::string &name,
26+
const std::shared_ptr<CallInvoker> &jsInvoker) {
2727
// Not implemented yet: provide pure-C++ NativeModules here.
2828
return nullptr;
2929
}
3030

3131
std::shared_ptr<TurboModule>
3232
MainApplicationTurboModuleManagerDelegate::getTurboModule(
33-
const std::string name,
33+
const std::string &name,
3434
const JavaTurboModule::InitParams &params) {
3535
return MainApplicationModuleProvider(name, params);
3636
}
3737

3838
bool MainApplicationTurboModuleManagerDelegate::canCreateTurboModule(
39-
std::string name) {
39+
const std::string &name) {
4040
return getTurboModule(name, nullptr) != nullptr ||
4141
getTurboModule(name, {.moduleName = name}) != nullptr;
4242
}

template/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ class MainApplicationTurboModuleManagerDelegate
2121
static void registerNatives();
2222

2323
std::shared_ptr<TurboModule> getTurboModule(
24-
const std::string name,
25-
const std::shared_ptr<CallInvoker> jsInvoker) override;
24+
const std::string &name,
25+
const std::shared_ptr<CallInvoker> &jsInvoker) override;
2626
std::shared_ptr<TurboModule> getTurboModule(
27-
const std::string name,
27+
const std::string &name,
2828
const JavaTurboModule::InitParams &params) override;
2929

3030
/**
3131
* Test-only method. Allows user to verify whether a TurboModule can be
3232
* created by instances of this class.
3333
*/
34-
bool canCreateTurboModule(std::string name);
34+
bool canCreateTurboModule(const std::string &name);
3535
};
3636

3737
} // namespace react

0 commit comments

Comments
 (0)