Skip to content

Commit f53a567

Browse files
committed
Fix performance issue with Structure.is_merge_node
1 parent 47b8477 commit f53a567

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

compiler/lib/structure.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ let is_forward g pc pc' = Hashtbl.find g.block_order pc < Hashtbl.find g.block_o
4242
let is_merge_node' block_order preds pc =
4343
let s = try Hashtbl.find preds pc with Not_found -> Addr.Set.empty in
4444
let o = Hashtbl.find block_order pc in
45-
let n =
46-
Addr.Set.fold (fun pc' n -> if Hashtbl.find block_order pc' < o then n + 1 else n) s 0
47-
in
48-
n > 1
45+
match Addr.Set.find_first_opt (fun pc' -> Hashtbl.find block_order pc' < o) s with
46+
| None -> false
47+
| Some pc' ->
48+
Addr.Set.exists (fun pc'' -> pc'' <> pc' && Hashtbl.find block_order pc'' < o) s
4949

5050
let empty_body body =
5151
List.for_all

0 commit comments

Comments
 (0)