summaryrefslogtreecommitdiff
path: root/runtime/ops
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2023-03-17 16:15:27 -0600
committerGitHub <noreply@github.com>2023-03-17 22:15:27 +0000
commit3487fde236d0852a8b0672c293fa41a741f471e8 (patch)
treeaf466368147a08b787080446319a3a46a60ee37d /runtime/ops
parente55b448730160a6e4df9815a268d4049ac89deab (diff)
perf(core) Reduce copying and cloning in extension initialization (#18252)
Follow-up to #18210: * we are passing the generated `cfg` object into the state function rather than passing individual config fields * reduce cloning dramatically by making the state_fn `FnOnce` * `take` for `ExtensionBuilder` to avoid more unnecessary copies * renamed `config` to `options`
Diffstat (limited to 'runtime/ops')
-rw-r--r--runtime/ops/os/mod.rs6
-rw-r--r--runtime/ops/runtime.rs6
-rw-r--r--runtime/ops/worker_host.rs12
3 files changed, 12 insertions, 12 deletions
diff --git a/runtime/ops/os/mod.rs b/runtime/ops/os/mod.rs
index 87181654b..b34629395 100644
--- a/runtime/ops/os/mod.rs
+++ b/runtime/ops/os/mod.rs
@@ -42,11 +42,11 @@ deno_core::ops!(
deno_core::extension!(
deno_os,
ops_fn = deno_ops,
- config = {
+ options = {
exit_code: ExitCode,
},
- state = |state, exit_code| {
- state.put::<ExitCode>(exit_code);
+ state = |state, options| {
+ state.put::<ExitCode>(options.exit_code);
},
);
diff --git a/runtime/ops/runtime.rs b/runtime/ops/runtime.rs
index 564d2279b..a77e888c8 100644
--- a/runtime/ops/runtime.rs
+++ b/runtime/ops/runtime.rs
@@ -9,9 +9,9 @@ use deno_core::OpState;
deno_core::extension!(
deno_runtime,
ops = [op_main_module],
- config = { main_module: ModuleSpecifier },
- state = |state, main_module| {
- state.put::<ModuleSpecifier>(main_module);
+ options = { main_module: ModuleSpecifier },
+ state = |state, options| {
+ state.put::<ModuleSpecifier>(options.main_module);
}
);
diff --git a/runtime/ops/worker_host.rs b/runtime/ops/worker_host.rs
index de7e02e18..26c99efab 100644
--- a/runtime/ops/worker_host.rs
+++ b/runtime/ops/worker_host.rs
@@ -96,27 +96,27 @@ deno_core::extension!(
op_host_recv_ctrl,
op_host_recv_message,
],
- config = {
+ options = {
create_web_worker_cb: Arc<CreateWebWorkerCb>,
preload_module_cb: Arc<WorkerEventCb>,
pre_execute_module_cb: Arc<WorkerEventCb>,
format_js_error_fn: Option<Arc<FormatJsErrorFn>>,
},
- state = |state, create_web_worker_cb, preload_module_cb, pre_execute_module_cb, format_js_error_fn| {
+ state = |state, options| {
state.put::<WorkersTable>(WorkersTable::default());
state.put::<WorkerId>(WorkerId::default());
let create_web_worker_cb_holder =
- CreateWebWorkerCbHolder(create_web_worker_cb.clone());
+ CreateWebWorkerCbHolder(options.create_web_worker_cb);
state.put::<CreateWebWorkerCbHolder>(create_web_worker_cb_holder);
let preload_module_cb_holder =
- PreloadModuleCbHolder(preload_module_cb.clone());
+ PreloadModuleCbHolder(options.preload_module_cb);
state.put::<PreloadModuleCbHolder>(preload_module_cb_holder);
let pre_execute_module_cb_holder =
- PreExecuteModuleCbHolder(pre_execute_module_cb.clone());
+ PreExecuteModuleCbHolder(options.pre_execute_module_cb);
state.put::<PreExecuteModuleCbHolder>(pre_execute_module_cb_holder);
let format_js_error_fn_holder =
- FormatJsErrorFnHolder(format_js_error_fn.clone());
+ FormatJsErrorFnHolder(options.format_js_error_fn);
state.put::<FormatJsErrorFnHolder>(format_js_error_fn_holder);
}
);