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/websocket/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'ext/websocket') 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, unsafely_ignore_certificate_errors: Option> }, - state = |state, user_agent, root_cert_store, unsafely_ignore_certificate_errors| { - state.put::(WsUserAgent(user_agent)); + state = |state, options| { + state.put::(WsUserAgent(options.user_agent)); state.put(UnsafelyIgnoreCertificateErrors( - unsafely_ignore_certificate_errors, + options.unsafely_ignore_certificate_errors, )); - state.put::(WsRootStore(root_cert_store)); + state.put::(WsRootStore(options.root_cert_store)); }, ); -- cgit v1.2.3