diff options
author | Matt Mastracci <matthew@mastracci.com> | 2023-03-17 16:15:27 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-17 22:15:27 +0000 |
commit | 3487fde236d0852a8b0672c293fa41a741f471e8 (patch) | |
tree | af466368147a08b787080446319a3a46a60ee37d /ext/net/lib.rs | |
parent | e55b448730160a6e4df9815a268d4049ac89deab (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 'ext/net/lib.rs')
-rw-r--r-- | ext/net/lib.rs | 10 |
1 files changed, 5 insertions, 5 deletions
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<P>, ], esm = [ "01_net.js", "02_tls.js" ], - config = { + options = { root_cert_store: Option<RootCertStore>, unstable: bool, unsafely_ignore_certificate_errors: Option<Vec<String>>, }, - 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, )); }, ); |