Skip to content

Commit 9e2d0ec

Browse files
committed
use iter instead of folder
1 parent da1a0a2 commit 9e2d0ec

File tree

5 files changed

+771
-775
lines changed

5 files changed

+771
-775
lines changed

jscomp/core/js_fold_basic.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
let add_lam_module_ident = Lam_module_ident.Hash_set.add
2929
let create = Lam_module_ident.Hash_set.create
3030
let count_hard_dependencies hard_dependencies =
31-
object(self : 'self_type)
32-
inherit Js_fold.fold as super
31+
object
32+
inherit Js_iter.iter as super
3333
method! module_id vid =
34-
add_lam_module_ident hard_dependencies vid; self
35-
method! expression x : 'self_type =
34+
add_lam_module_ident hard_dependencies vid
35+
method! expression x =
3636
(* check {!Js_pass_scope} when making changes *)
3737
(match Js_block_runtime.check_additional_id x with
3838
| Some id ->
@@ -45,7 +45,7 @@ let count_hard_dependencies hard_dependencies =
4545

4646
let calculate_hard_dependencies block =
4747
let hard_dependencies = create 17 in
48-
let _ : Js_fold.fold = (count_hard_dependencies hard_dependencies)#block block in
48+
(count_hard_dependencies hard_dependencies)#block block ;
4949
hard_dependencies
5050

5151
(*

jscomp/core/js_pass_flatten_and_mark_dead.ml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ type meta_info =
4343
let mark_dead_code (js : J.program) : J.program =
4444
let ident_use_stats : meta_info Hash_ident.t
4545
= Hash_ident.create 17 in
46-
let mark_dead : Js_fold.fold = object (self)
47-
inherit Js_fold.fold
46+
let mark_dead : Js_iter.iter = object (self)
47+
inherit Js_iter.iter
4848
method! ident ident =
4949
(match Hash_ident.find_opt ident_use_stats ident with
5050
| None -> (* First time *)
@@ -53,22 +53,21 @@ let mark_dead_code (js : J.program) : J.program =
5353
| Some Recursive
5454
-> ()
5555
| Some (Info x) -> Js_op_util.update_used_stats x Used )
56-
; self
5756
method! variable_declaration vd =
5857
match vd.ident_info.used_stats with
5958
| Dead_pure
60-
-> self
59+
-> ()
6160
| Dead_non_pure ->
6261
begin match vd.value with
63-
| None -> self
62+
| None -> ()
6463
| Some x -> self#expression x
6564
end
6665
| _ ->
6766
let ({ident; ident_info ; value ; _} : J.variable_declaration) = vd in
6867
let pure =
6968
match value with
7069
| None -> true
71-
| Some x -> ignore (self#expression x); Js_analyzer.no_side_effect_expression x in
70+
| Some x -> (self#expression x); Js_analyzer.no_side_effect_expression x in
7271
(
7372
let () =
7473
if Set_ident.mem js.export_set ident then
@@ -87,9 +86,9 @@ let mark_dead_code (js : J.program) : J.program =
8786
| None -> (* First time *)
8887
Hash_ident.add ident_use_stats ident (Info ident_info);
8988
Js_op_util.update_used_stats ident_info
90-
(if pure then Scanning_pure else Scanning_non_pure)); self
89+
(if pure then Scanning_pure else Scanning_non_pure))
9190
end in
92-
let _ = (mark_dead#program js) in
91+
let () = (mark_dead#program js) in
9392
Hash_ident.iter ident_use_stats (fun _id (info : meta_info) ->
9493
match info with
9594
| Info ({used_stats = Scanning_pure} as info) ->

0 commit comments

Comments
 (0)