Skip to content

Commit 5ad0433

Browse files
committedMar 5, 2018
remove if e == 0 then f else t => if e then t else f transformation in statement
1 parent c58dbb3 commit 5ad0433

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+2413
-2531
lines changed
 

‎jscomp/core/js_exp_make.ml

+13-6
Original file line numberDiff line numberDiff line change
@@ -851,19 +851,13 @@ let string_of_small_int_array ?comment xs : t =
851851
call plain [dot]
852852
*)
853853

854-
let null ?comment () =
855-
js_global ?comment "null"
856854

857855
let tag ?comment e : t =
858856
{expression_desc =
859857
Bin (Bor, {expression_desc = Caml_block_tag e; comment }, zero_int_literal );
860858
comment = None }
861859

862860

863-
let bind ?comment fn obj : t =
864-
{expression_desc = Bind (fn, obj) ; comment }
865-
866-
867861
(* according to the compiler, [Btype.hash_variant],
868862
it's reduced to 31 bits for hash
869863
*)
@@ -985,6 +979,19 @@ let rec int_comp (cmp : Lambda.comparison) ?comment (e0 : t) (e1 : t) =
985979
[l;r], _),
986980
Number (Int {i = 0l})
987981
-> int_comp cmp l r (* = 0 > 0 < 0 *)
982+
(* | Ceq, Call ({
983+
expression_desc =
984+
Var (Qualified
985+
(ident, Runtime,
986+
Some ("caml_compare"))); _} as fn,
987+
([l;r] as args), call_info),
988+
Number (Int {i = 0l})
989+
->
990+
{e0 with expression_desc =
991+
Call(
992+
{fn with expression_desc =
993+
Var(Qualified (ident,Runtime, Some "caml_equal"))
994+
} , args, call_info)} *)
988995
| Ceq, _, _ -> int_equal e0 e1
989996
| _ ->
990997
bool_of_boolean @@ bin ?comment (Lam_compile_util.jsop_of_comp cmp) e0 e1

‎jscomp/core/js_exp_make.mli

-2
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,6 @@ val dummy_obj : ?comment:string -> unit -> t
336336
(** convert a block to expresion by using IIFE *)
337337
val of_block : ?comment:string -> ?e:J.expression -> J.statement list -> t
338338

339-
val bind : binary_op
340-
341339
val raw_js_code : ?comment:string -> J.code_info -> string -> t
342340

343341
val nil : t

0 commit comments

Comments
 (0)