summaryrefslogtreecommitdiff
path: root/runtime/worker.rs
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/worker.rs
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/worker.rs')
-rw-r--r--runtime/worker.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/runtime/worker.rs b/runtime/worker.rs
index 8a7f5711d..ed3478ff0 100644
--- a/runtime/worker.rs
+++ b/runtime/worker.rs
@@ -1,6 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
-use std::cell::RefCell;
use std::pin::Pin;
use std::rc::Rc;
use std::sync::atomic::AtomicI32;
@@ -189,15 +188,15 @@ impl MainWorker {
mut options: WorkerOptions,
) -> Self {
deno_core::extension!(deno_permissions_worker,
- config = {
+ options = {
permissions: PermissionsContainer,
unstable: bool,
enable_testing_features: bool,
},
- state = |state, permissions, unstable, enable_testing_features| {
- state.put::<PermissionsContainer>(permissions);
- state.put(ops::UnstableChecker { unstable });
- state.put(ops::TestingFeaturesEnabled(enable_testing_features));
+ state = |state, options| {
+ state.put::<PermissionsContainer>(options.permissions);
+ state.put(ops::UnstableChecker { unstable: options.unstable });
+ state.put(ops::TestingFeaturesEnabled(options.enable_testing_features));
},
);
@@ -255,7 +254,7 @@ impl MainWorker {
deno_tls::deno_tls::init_ops(),
deno_napi::deno_napi::init_ops::<PermissionsContainer>(),
deno_http::deno_http::init_ops(),
- deno_io::deno_io::init_ops(Rc::new(RefCell::new(Some(options.stdio)))),
+ deno_io::deno_io::init_ops(Some(options.stdio)),
deno_fs::deno_fs::init_ops::<PermissionsContainer>(unstable),
deno_flash::deno_flash::init_ops::<PermissionsContainer>(unstable),
deno_node::deno_node_loading::init_ops::<PermissionsContainer>(