Skip to content

Commit

Permalink
refactor(es/preset-env): Rename parameter to avoid confusion (#8106)
Browse files Browse the repository at this point in the history
**Related issue:**

 - Closes #8103
  • Loading branch information
kdy1 authored Oct 12, 2023
1 parent 1bb2491 commit 95eb147
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions crates/swc_ecma_preset_env/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ mod regenerator;
mod transform_data;

pub fn preset_env<C>(
global_mark: Mark,
unresolved_mark: Mark,
comments: Option<C>,
c: Config,
assumptions: Assumptions,
Expand Down Expand Up @@ -178,7 +178,7 @@ where
no_document_all: loose || assumptions.no_document_all,
pure_getter: loose || assumptions.pure_getters
},
global_mark
unresolved_mark
)
);

Expand Down Expand Up @@ -206,7 +206,7 @@ where
ignore_function_length: loose || assumptions.ignore_function_length,
},
comments.clone(),
global_mark
unresolved_mark
)
);

Expand Down Expand Up @@ -245,7 +245,7 @@ where
);
let pass = add!(pass, ObjectSuper, es2015::object_super());
let pass = add!(pass, FunctionName, es2015::function_name());
let pass = add!(pass, ArrowFunctions, es2015::arrow(global_mark));
let pass = add!(pass, ArrowFunctions, es2015::arrow(unresolved_mark));
let pass = add!(pass, DuplicateKeys, es2015::duplicate_keys());
let pass = add!(pass, StickyRegex, es2015::sticky_regex());
// TODO: InstanceOf,
Expand All @@ -258,7 +258,7 @@ where
es2015::parameters::Config {
ignore_function_length: loose || assumptions.ignore_function_length
},
global_mark
unresolved_mark
)
);
let pass = add!(
Expand All @@ -282,8 +282,18 @@ where
es2015::destructuring(es2015::destructuring::Config { loose }),
true
);
let pass = add!(pass, BlockScoping, es2015::block_scoping(global_mark), true);
let pass = add!(pass, Regenerator, generator(global_mark, comments), true);
let pass = add!(
pass,
BlockScoping,
es2015::block_scoping(unresolved_mark),
true
);
let pass = add!(
pass,
Regenerator,
generator(unresolved_mark, comments),
true
);

let pass = add!(pass, NewTarget, es2015::new_target(), true);

Expand Down Expand Up @@ -311,7 +321,7 @@ where
let pass = add!(
pass,
BugfixAsyncArrowsInClass,
bugfixes::async_arrows_in_class(global_mark)
bugfixes::async_arrows_in_class(unresolved_mark)
);
let pass = add!(
pass,
Expand Down Expand Up @@ -342,7 +352,7 @@ where
targets,
includes: included_modules,
excludes: excluded_modules,
global_mark
unresolved_mark,
})
)
}
Expand All @@ -356,7 +366,7 @@ struct Polyfills {
regenerator: bool,
includes: AHashSet<String>,
excludes: AHashSet<String>,
global_mark: Mark,
unresolved_mark: Mark,
}
impl Polyfills {
fn collect<T>(&mut self, m: &mut T) -> Vec<JsWord>
Expand Down Expand Up @@ -496,7 +506,7 @@ impl VisitMut for Polyfills {
expr: CallExpr {
span,
callee: Expr::Ident(Ident {
span: DUMMY_SP.apply_mark(self.global_mark),
span: DUMMY_SP.apply_mark(self.unresolved_mark),
sym: "require".into(),
optional: false,
})
Expand All @@ -522,7 +532,7 @@ impl VisitMut for Polyfills {
expr: CallExpr {
span,
callee: Expr::Ident(Ident {
span: DUMMY_SP.apply_mark(self.global_mark),
span: DUMMY_SP.apply_mark(self.unresolved_mark),
sym: "require".into(),
optional: false,
})
Expand Down

1 comment on commit 95eb147

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 95eb147 Previous: fe0bf57 Ratio
es/full/bugs-1 283878 ns/iter (± 3067) 285611 ns/iter (± 5590) 0.99
es/full/minify/libraries/antd 1406883881 ns/iter (± 8879115) 1438373802 ns/iter (± 13374577) 0.98
es/full/minify/libraries/d3 293599943 ns/iter (± 3035172) 299550483 ns/iter (± 6046695) 0.98
es/full/minify/libraries/echarts 1130929271 ns/iter (± 9248504) 1153468143 ns/iter (± 14326306) 0.98
es/full/minify/libraries/jquery 89189602 ns/iter (± 203587) 91121204 ns/iter (± 790513) 0.98
es/full/minify/libraries/lodash 104530182 ns/iter (± 242211) 104660793 ns/iter (± 286351) 1.00
es/full/minify/libraries/moment 52515477 ns/iter (± 125490) 52682938 ns/iter (± 146697) 1.00
es/full/minify/libraries/react 18908008 ns/iter (± 78663) 18934411 ns/iter (± 103423) 1.00
es/full/minify/libraries/terser 231022536 ns/iter (± 1218303) 233239288 ns/iter (± 2822767) 0.99
es/full/minify/libraries/three 413703566 ns/iter (± 3313253) 427862427 ns/iter (± 7384046) 0.97
es/full/minify/libraries/typescript 2810993528 ns/iter (± 9787817) 2832806751 ns/iter (± 20226101) 0.99
es/full/minify/libraries/victory 603094922 ns/iter (± 9467271) 615402861 ns/iter (± 14641833) 0.98
es/full/minify/libraries/vue 126542277 ns/iter (± 496333) 128835248 ns/iter (± 645929) 0.98
es/full/codegen/es3 33273 ns/iter (± 98) 33547 ns/iter (± 74) 0.99
es/full/codegen/es5 33293 ns/iter (± 85) 33569 ns/iter (± 78) 0.99
es/full/codegen/es2015 33319 ns/iter (± 67) 33623 ns/iter (± 76) 0.99
es/full/codegen/es2016 33280 ns/iter (± 99) 33653 ns/iter (± 48) 0.99
es/full/codegen/es2017 33175 ns/iter (± 104) 33611 ns/iter (± 43) 0.99
es/full/codegen/es2018 33259 ns/iter (± 93) 33646 ns/iter (± 101) 0.99
es/full/codegen/es2019 33382 ns/iter (± 57) 33638 ns/iter (± 83) 0.99
es/full/codegen/es2020 33324 ns/iter (± 245) 33612 ns/iter (± 66) 0.99
es/full/all/es3 175703794 ns/iter (± 2624889) 177380373 ns/iter (± 1389833) 0.99
es/full/all/es5 168448590 ns/iter (± 833592) 169948114 ns/iter (± 1299397) 0.99
es/full/all/es2015 128870231 ns/iter (± 1190466) 129206315 ns/iter (± 969763) 1.00
es/full/all/es2016 127361561 ns/iter (± 606861) 128129997 ns/iter (± 919357) 0.99
es/full/all/es2017 126341294 ns/iter (± 787707) 128511023 ns/iter (± 747708) 0.98
es/full/all/es2018 124353621 ns/iter (± 999031) 126000247 ns/iter (± 992485) 0.99
es/full/all/es2019 124431922 ns/iter (± 763936) 125752845 ns/iter (± 412170) 0.99
es/full/all/es2020 120315438 ns/iter (± 1131193) 121490914 ns/iter (± 495754) 0.99
es/full/parser 565289 ns/iter (± 3775) 570716 ns/iter (± 3435) 0.99
es/full/base/fixer 19222 ns/iter (± 105) 20362 ns/iter (± 377) 0.94
es/full/base/resolver_and_hygiene 85551 ns/iter (± 329) 85998 ns/iter (± 270) 0.99

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.