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` --- cli/ops/bench.rs | 8 ++++---- cli/ops/mod.rs | 6 +++--- cli/ops/testing.rs | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'cli/ops') diff --git a/cli/ops/bench.rs b/cli/ops/bench.rs index 7bd3f988a..6fa9edee8 100644 --- a/cli/ops/bench.rs +++ b/cli/ops/bench.rs @@ -30,13 +30,13 @@ deno_core::extension!(deno_bench, op_dispatch_bench_event, op_bench_now, ], - config = { + options = { sender: UnboundedSender, filter: TestFilter, }, - state = |state, sender, filter| { - state.put(sender); - state.put(filter); + state = |state, options| { + state.put(options.sender); + state.put(options.filter); }, ); diff --git a/cli/ops/mod.rs b/cli/ops/mod.rs index 562aa8649..c12409514 100644 --- a/cli/ops/mod.rs +++ b/cli/ops/mod.rs @@ -15,11 +15,11 @@ pub fn cli_exts(ps: ProcState) -> Vec { deno_core::extension!(deno_cli, ops = [op_npm_process_state], - config = { + options = { ps: ProcState, }, - state = |state, ps| { - state.put(ps); + state = |state, options| { + state.put(options.ps); }, ); diff --git a/cli/ops/testing.rs b/cli/ops/testing.rs index f32e96147..0849f1c7a 100644 --- a/cli/ops/testing.rs +++ b/cli/ops/testing.rs @@ -34,15 +34,15 @@ deno_core::extension!(deno_test, op_dispatch_test_event, op_tests_should_stop, ], - config = { + options = { sender: TestEventSender, fail_fast_tracker: FailFastTracker, filter: TestFilter, }, - state = |state, sender, fail_fast_tracker, filter| { - state.put(sender); - state.put(fail_fast_tracker); - state.put(filter); + state = |state, options| { + state.put(options.sender); + state.put(options.fail_fast_tracker); + state.put(options.filter); }, ); -- cgit v1.2.3