Skip to content

Commit

Permalink
patch case test judgement
Browse files Browse the repository at this point in the history
  • Loading branch information
CPunisher committed Jul 11, 2024
1 parent da9844b commit 8759d76
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/swc_ecma_minifier/src/compress/optimize/switches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ impl Optimizer<'_> {
for (idx, case) in stmt.cases.iter_mut().enumerate() {
if let Some(test) = case.test.as_ref() {
if let Some(e) = is_primitive(&self.expr_ctx, tail_expr(test)) {
if e.eq_ignore_span(tail) {
if match (e, tail) {
(Expr::Lit(Lit::Num(e)), Expr::Lit(Lit::Num(tail))) => {
e.value == tail.value
}
_ => e.eq_ignore_span(tail),
} {
cases.push(case.take());

exact = Some(idx);
Expand Down

0 comments on commit 8759d76

Please sign in to comment.