Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize arg conversion in SurfaceRegistryBinding #39094

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ void SurfaceRegistryBinding::startSurface(
folly::dynamic const &initialProps,
DisplayMode displayMode) {
SystraceSection s("SurfaceRegistryBinding::startSurface");
folly::dynamic parameters = folly::dynamic::object();
parameters["rootTag"] = surfaceId;
parameters["initialProps"] = initialProps;
parameters["fabric"] = true;
jsi::Object parameters(runtime);
parameters.setProperty(runtime, "rootTag", surfaceId);
parameters.setProperty(
runtime, "initialProps", jsi::valueFromDynamic(runtime, initialProps));
parameters.setProperty(runtime, "fabric", true);

auto global = runtime.global();
auto registry = global.getProperty(runtime, "RN$AppRegistry");
Expand All @@ -49,7 +50,7 @@ void SurfaceRegistryBinding::startSurface(
method.call(
runtime,
{jsi::String::createFromUtf8(runtime, moduleName),
jsi::valueFromDynamic(runtime, parameters),
std::move(parameters),
jsi::Value(runtime, displayModeToInt(displayMode))});
} else {
throwIfBridgeless(runtime, global, "startSurface");
Expand All @@ -58,7 +59,7 @@ void SurfaceRegistryBinding::startSurface(
"AppRegistry",
"runApplication",
{jsi::String::createFromUtf8(runtime, moduleName),
jsi::valueFromDynamic(runtime, parameters),
std::move(parameters),
jsi::Value(runtime, displayModeToInt(displayMode))});
}
}
Expand All @@ -70,10 +71,11 @@ void SurfaceRegistryBinding::setSurfaceProps(
folly::dynamic const &initialProps,
DisplayMode displayMode) {
SystraceSection s("UIManagerBinding::setSurfaceProps");
folly::dynamic parameters = folly::dynamic::object();
parameters["rootTag"] = surfaceId;
parameters["initialProps"] = initialProps;
parameters["fabric"] = true;
jsi::Object parameters(runtime);
parameters.setProperty(runtime, "rootTag", surfaceId);
parameters.setProperty(
runtime, "initialProps", jsi::valueFromDynamic(runtime, initialProps));
parameters.setProperty(runtime, "fabric", true);

auto global = runtime.global();
auto registry = global.getProperty(runtime, "RN$AppRegistry");
Expand All @@ -83,7 +85,7 @@ void SurfaceRegistryBinding::setSurfaceProps(
method.call(
runtime,
{jsi::String::createFromUtf8(runtime, moduleName),
jsi::valueFromDynamic(runtime, parameters),
std::move(parameters),
jsi::Value(runtime, displayModeToInt(displayMode))});
} else {
throwIfBridgeless(runtime, global, "setSurfaceProps");
Expand All @@ -92,7 +94,7 @@ void SurfaceRegistryBinding::setSurfaceProps(
"AppRegistry",
"setSurfaceProps",
{jsi::String::createFromUtf8(runtime, moduleName),
jsi::valueFromDynamic(runtime, parameters),
std::move(parameters),
jsi::Value(runtime, displayModeToInt(displayMode))});
}
}
Expand Down