From 3487fde236d0852a8b0672c293fa41a741f471e8 Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Fri, 17 Mar 2023 16:15:27 -0600 Subject: 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` --- ext/node/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ext/node') diff --git a/ext/node/lib.rs b/ext/node/lib.rs index 06138cf4c..23a003bc8 100644 --- a/ext/node/lib.rs +++ b/ext/node/lib.rs @@ -370,11 +370,11 @@ deno_core::extension!(deno_node_loading, ops::op_require_break_on_next_statement, ], esm = ["01_node.js", "02_require.js", "module_es_shim.js"], - config = { + options = { maybe_npm_resolver: Option>, }, - state = |state, maybe_npm_resolver| { - if let Some(npm_resolver) = maybe_npm_resolver.clone() { + state = |state, options| { + if let Some(npm_resolver) = options.maybe_npm_resolver { state.put(npm_resolver); } }, -- cgit v1.2.3