Remove a bunch of copies

Reviewed By: astreet

Differential Revision: D3475592

fbshipit-source-id: 37148bb8d8d47e9301ad549b183029337f7c4ca0
This commit is contained in:
Alexander Blom 2016-07-07 08:44:01 -07:00 committed by Facebook Github Bot 1
parent 95401aba72
commit be0abd17e5
5 changed files with 17 additions and 18 deletions

View File

@ -297,8 +297,8 @@ void CatalystInstanceImpl::callJSFunction(
// strings otherwise. Eventually, we'll probably want to modify the stack
// from the JS proxy through here to use strings, too.
instance_->callJSFunction(token->getExecutorToken(nullptr),
module,
method,
std::move(module),
std::move(method),
std::move(arguments->array));
}

View File

@ -101,10 +101,10 @@ void Instance::setGlobalVariable(std::string propName,
nativeToJsBridge_->setGlobalVariable(std::move(propName), std::move(jsonValue));
}
void Instance::callJSFunction(ExecutorToken token, const std::string& module, const std::string& method,
void Instance::callJSFunction(ExecutorToken token, std::string&& module, std::string&& method,
folly::dynamic&& params) {
callback_->incrementPendingJSCalls();
nativeToJsBridge_->callFunction(token, module, method, std::move(params));
nativeToJsBridge_->callFunction(token, std::move(module), std::move(method), std::move(params));
}
void Instance::callJSCallback(ExecutorToken token, uint64_t callbackId, folly::dynamic&& params) {

View File

@ -44,7 +44,7 @@ class Instance {
void startProfiler(const std::string& title);
void stopProfiler(const std::string& title, const std::string& filename);
void setGlobalVariable(std::string propName, std::unique_ptr<const JSBigString> jsonValue);
void callJSFunction(ExecutorToken token, const std::string& module, const std::string& method,
void callJSFunction(ExecutorToken token, std::string&& module, std::string&& method,
folly::dynamic&& params);
void callJSCallback(ExecutorToken token, uint64_t callbackId, folly::dynamic&& params);
MethodCallResult callSerializableNativeHook(ExecutorToken token, unsigned int moduleId,

View File

@ -143,14 +143,14 @@ void NativeToJsBridge::loadApplicationUnbundle(
void NativeToJsBridge::callFunction(
ExecutorToken executorToken,
const std::string& moduleId,
const std::string& methodId,
const folly::dynamic& arguments) {
std::string&& module,
std::string&& method,
folly::dynamic&& arguments) {
int systraceCookie = -1;
#ifdef WITH_FBSYSTRACE
systraceCookie = m_systraceCookie++;
std::string tracingName = fbsystrace_is_tracing(TRACE_TAG_REACT_CXX_BRIDGE) ?
folly::to<std::string>("JSCall__", moduleId, '_', methodId) : std::string();
folly::to<std::string>("JSCall__", module, '_', method) : std::string();
SystraceSection s(tracingName.c_str());
FbSystraceAsyncFlow::begin(
TRACE_TAG_REACT_CXX_BRIDGE,
@ -160,7 +160,7 @@ void NativeToJsBridge::callFunction(
std::string tracingName;
#endif
runOnExecutorQueue(executorToken, [moduleId, methodId, arguments, tracingName = std::move(tracingName), systraceCookie] (JSExecutor* executor) {
runOnExecutorQueue(executorToken, [module = std::move(module), method = std::move(method), arguments = std::move(arguments), tracingName = std::move(tracingName), systraceCookie] (JSExecutor* executor) {
#ifdef WITH_FBSYSTRACE
FbSystraceAsyncFlow::end(
TRACE_TAG_REACT_CXX_BRIDGE,
@ -172,12 +172,11 @@ void NativeToJsBridge::callFunction(
// This is safe because we are running on the executor's thread: it won't
// destruct until after it's been unregistered (which we check above) and
// that will happen on this thread
executor->callFunction(moduleId, methodId, arguments);
executor->callFunction(module, method, arguments);
});
}
void NativeToJsBridge::invokeCallback(ExecutorToken executorToken, const double callbackId,
const folly::dynamic& arguments) {
void NativeToJsBridge::invokeCallback(ExecutorToken executorToken, double callbackId, folly::dynamic&& arguments) {
int systraceCookie = -1;
#ifdef WITH_FBSYSTRACE
systraceCookie = m_systraceCookie++;
@ -187,7 +186,7 @@ void NativeToJsBridge::invokeCallback(ExecutorToken executorToken, const double
systraceCookie);
#endif
runOnExecutorQueue(executorToken, [callbackId, arguments, systraceCookie] (JSExecutor* executor) {
runOnExecutorQueue(executorToken, [callbackId, arguments = std::move(arguments), systraceCookie] (JSExecutor* executor) {
#ifdef WITH_FBSYSTRACE
FbSystraceAsyncFlow::end(
TRACE_TAG_REACT_CXX_BRIDGE,

View File

@ -68,14 +68,14 @@ public:
*/
void callFunction(
ExecutorToken executorToken,
const std::string& moduleId,
const std::string& methodId,
const folly::dynamic& args);
std::string&& module,
std::string&& method,
folly::dynamic&& args);
/**
* Invokes a callback with the cbID, and optional additional arguments in JS.
*/
void invokeCallback(ExecutorToken executorToken, const double callbackId, const folly::dynamic& args);
void invokeCallback(ExecutorToken executorToken, double callbackId, folly::dynamic&& args);
/**
* Starts the JS application from an "bundle", i.e. a JavaScript file that