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/websocket/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/websocket/lib.rs')
-rw-r--r-- | ext/websocket/lib.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ext/websocket/lib.rs b/ext/websocket/lib.rs index e480d7f4c..24a290b4b 100644 --- a/ext/websocket/lib.rs +++ b/ext/websocket/lib.rs @@ -506,17 +506,17 @@ deno_core::extension!(deno_websocket, op_ws_next_event, ], esm = [ "01_websocket.js", "02_websocketstream.js" ], - config = { + options = { user_agent: String, root_cert_store: Option<RootCertStore>, unsafely_ignore_certificate_errors: Option<Vec<String>> }, - state = |state, user_agent, root_cert_store, unsafely_ignore_certificate_errors| { - state.put::<WsUserAgent>(WsUserAgent(user_agent)); + state = |state, options| { + state.put::<WsUserAgent>(WsUserAgent(options.user_agent)); state.put(UnsafelyIgnoreCertificateErrors( - unsafely_ignore_certificate_errors, + options.unsafely_ignore_certificate_errors, )); - state.put::<WsRootStore>(WsRootStore(root_cert_store)); + state.put::<WsRootStore>(WsRootStore(options.root_cert_store)); }, ); |