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/fetch/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/fetch/lib.rs')
-rw-r--r-- | ext/fetch/lib.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/ext/fetch/lib.rs b/ext/fetch/lib.rs index 4cd5d68c8..9ed73161d 100644 --- a/ext/fetch/lib.rs +++ b/ext/fetch/lib.rs @@ -107,19 +107,19 @@ deno_core::extension!(deno_fetch, "23_response.js", "26_fetch.js" ], - config = { + options = { options: Options, }, state = |state, options| { - state.put::<Options>(options.clone()); + state.put::<Options>(options.options.clone()); state.put::<reqwest::Client>({ create_http_client( - options.user_agent, - options.root_cert_store, + options.options.user_agent, + options.options.root_cert_store, vec![], - options.proxy, - options.unsafely_ignore_certificate_errors, - options.client_cert_chain_and_key + options.options.proxy, + options.options.unsafely_ignore_certificate_errors, + options.options.client_cert_chain_and_key ) .unwrap() }); |