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/net/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'ext/net') diff --git a/ext/net/lib.rs b/ext/net/lib.rs index 76ed02706..00833b53c 100644 --- a/ext/net/lib.rs +++ b/ext/net/lib.rs @@ -105,18 +105,18 @@ deno_core::extension!(deno_net, #[cfg(unix)] ops_unix::op_net_send_unixpacket

, ], esm = [ "01_net.js", "02_tls.js" ], - config = { + options = { root_cert_store: Option, unstable: bool, unsafely_ignore_certificate_errors: Option>, }, - state = |state, root_cert_store, unstable, unsafely_ignore_certificate_errors| { + state = |state, options| { state.put(DefaultTlsOptions { - root_cert_store, + root_cert_store: options.root_cert_store, }); - state.put(UnstableChecker { unstable }); + state.put(UnstableChecker { unstable: options.unstable }); state.put(UnsafelyIgnoreCertificateErrors( - unsafely_ignore_certificate_errors, + options.unsafely_ignore_certificate_errors, )); }, ); -- cgit v1.2.3