mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 02:48:24 +00:00
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`
This commit is contained in:
parent
e55b448730
commit
3487fde236
27 changed files with 206 additions and 174 deletions
|
@ -30,13 +30,13 @@ deno_core::extension!(deno_bench,
|
|||
op_dispatch_bench_event,
|
||||
op_bench_now,
|
||||
],
|
||||
config = {
|
||||
options = {
|
||||
sender: UnboundedSender<BenchEvent>,
|
||||
filter: TestFilter,
|
||||
},
|
||||
state = |state, sender, filter| {
|
||||
state.put(sender);
|
||||
state.put(filter);
|
||||
state = |state, options| {
|
||||
state.put(options.sender);
|
||||
state.put(options.filter);
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -15,11 +15,11 @@ pub fn cli_exts(ps: ProcState) -> Vec<Extension> {
|
|||
|
||||
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);
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -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);
|
||||
},
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue