Skip to content

Commit

Permalink
feat(codegen): minify case "foo" -> case"foo" (#8085)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Dec 24, 2024
1 parent 414c118 commit 8b8cbcd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions crates/oxc_codegen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,6 @@ impl Gen for SwitchStatement<'_> {
p.print_soft_space();
p.print_curly_braces(self.span, self.cases.is_empty(), |p| {
for case in &self.cases {
p.add_source_mapping(case.span);
case.print(p, ctx);
}
});
Expand All @@ -547,9 +546,11 @@ impl Gen for SwitchCase<'_> {
fn gen(&self, p: &mut Codegen, ctx: Context) {
p.print_semicolon_if_needed();
p.print_indent();
p.add_source_mapping(self.span);
match &self.test {
Some(test) => {
p.print_str("case ");
p.print_str("case");
p.print_soft_space();
p.print_expression(test);
}
None => p.print_str("default"),
Expand Down
14 changes: 7 additions & 7 deletions tasks/minsize/minsize.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ Original | minified | minified | gzip | gzip | Fixture
-------------------------------------------------------------------------------------
72.14 kB | 24.04 kB | 23.70 kB | 8.61 kB | 8.54 kB | react.development.js

173.90 kB | 61.60 kB | 59.82 kB | 19.54 kB | 19.33 kB | moment.js
173.90 kB | 61.55 kB | 59.82 kB | 19.54 kB | 19.33 kB | moment.js

287.63 kB | 92.60 kB | 90.07 kB | 32.27 kB | 31.95 kB | jquery.js

342.15 kB | 121.56 kB | 118.14 kB | 44.64 kB | 44.37 kB | vue.js
342.15 kB | 121.55 kB | 118.14 kB | 44.64 kB | 44.37 kB | vue.js

544.10 kB | 73.32 kB | 72.48 kB | 26.13 kB | 26.20 kB | lodash.js

555.77 kB | 276.08 kB | 270.13 kB | 91.14 kB | 90.80 kB | d3.js
555.77 kB | 276.06 kB | 270.13 kB | 91.14 kB | 90.80 kB | d3.js

1.01 MB | 467.00 kB | 458.89 kB | 126.74 kB | 126.71 kB | bundle.min.js
1.01 MB | 466.83 kB | 458.89 kB | 126.74 kB | 126.71 kB | bundle.min.js

1.25 MB | 661.60 kB | 646.76 kB | 163.94 kB | 163.73 kB | three.js
1.25 MB | 661.47 kB | 646.76 kB | 163.94 kB | 163.73 kB | three.js

2.14 MB | 740.48 kB | 724.14 kB | 181.35 kB | 181.07 kB | victory.js
2.14 MB | 740.44 kB | 724.14 kB | 181.35 kB | 181.07 kB | victory.js

3.20 MB | 1.02 MB | 1.01 MB | 332.01 kB | 331.56 kB | echarts.js
3.20 MB | 1.02 MB | 1.01 MB | 332.00 kB | 331.56 kB | echarts.js

6.69 MB | 2.39 MB | 2.31 MB | 495.62 kB | 488.28 kB | antd.js

Expand Down

0 comments on commit 8b8cbcd

Please sign in to comment.