Avoid string copy in event dispatching

Summary:
Changelog: [internal]

To avoid unnecessary string copy in event pipeline, use move semantics.

Event pipeline has ownership of event type. Passing it by reference ends up in a copy when `RawEvent` object is constructed. To avoid this, pass string by value through each layer and use move semantics to avoid extra copies.

Reviewed By: javache

Differential Revision: D34392608

fbshipit-source-id: c11d221be345665e165d9edbc360ba5a057e3890
This commit is contained in:
Samuel Susla
2022-03-08 04:28:51 -08:00
committed by Facebook GitHub Bot
parent 8200063ac6
commit e97e3499c3
10 changed files with 31 additions and 30 deletions
@@ -19,7 +19,7 @@ EventEmitterWrapper::initHybrid(jni::alias_ref<jclass>) {
}
void EventEmitterWrapper::invokeEvent(
std::string const &eventName,
std::string eventName,
NativeMap *payload,
int category) {
// It is marginal, but possible for this to be constructed without a valid
@@ -35,7 +35,7 @@ void EventEmitterWrapper::invokeEvent(
}
void EventEmitterWrapper::invokeUniqueEvent(
std::string const &eventName,
std::string eventName,
NativeMap *payload,
int customCoalesceKey) {
// TODO: customCoalesceKey currently unused
@@ -25,10 +25,9 @@ class EventEmitterWrapper : public jni::HybridClass<EventEmitterWrapper> {
SharedEventEmitter eventEmitter;
void
invokeEvent(std::string const &eventName, NativeMap *params, int category);
void invokeEvent(std::string eventName, NativeMap *params, int category);
void invokeUniqueEvent(
std::string const &eventName,
std::string eventName,
NativeMap *params,
int customCoalesceKey);