Skip to content

Commit 8ff9827

Browse files
committed
centralize emission logic for instanceof checks
1 parent 5a03d2f commit 8ff9827

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

jscomp/core/lam_compile.ml

+1-5
Original file line numberDiff line numberDiff line change
@@ -768,12 +768,8 @@ and compile_untagged_cases ~cxt ~switch_exp ~default ~block_cases cases =
768768
let switch ?default ?declaration e clauses =
769769
let (not_typeof_clauses, typeof_clauses) = List.partition is_not_typeof clauses in
770770
let rec build_if_chain remaining_clauses = (match remaining_clauses with
771-
| (Ast_untagged_variants.Untagged (InstanceType Array), {J.switch_body}) :: rest ->
772-
S.if_ (E.is_array e)
773-
(switch_body)
774-
~else_:([build_if_chain rest])
775771
| (Ast_untagged_variants.Untagged (InstanceType instanceType), {J.switch_body}) :: rest ->
776-
S.if_ (E.instanceof e (E.js_global (Ast_untagged_variants.Instance.to_string instanceType)))
772+
S.if_ (E.emit_check (IsInstanceOf (instanceType, Expr e)))
777773
(switch_body)
778774
~else_:([build_if_chain rest])
779775
| _ -> S.string_switch ?default ?declaration (E.typeof e) typeof_clauses) in

0 commit comments

Comments
 (0)