Skip to content

Commit ab58423

Browse files
committed
faster ?
1 parent aa4594b commit ab58423

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

compiler/lib/eval.ml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -816,22 +816,25 @@ let eval_branch blocks update_branch info l =
816816
incr update_branch;
817817
Branch cont
818818
| None ->
819-
let t = SBT.create 0 in
820-
let seen_pc = Addr.Hashtbl.create 0 in
819+
let t = lazy (SBT.create 0) in
820+
let seen_pc = ref IntSet.empty in
821821
Switch
822822
( x
823823
, Array.map a ~f:(function
824-
| pc, [] when not (Addr.Hashtbl.mem seen_pc pc) -> (
824+
| (pc, []) as cont when not (IntSet.mem pc !seen_pc) ->
825825
let block = Code.Addr.Map.find pc blocks in
826-
let sb = Simple_block.make block in
827-
match SBT.find_opt t sb with
828-
| Some pc' when pc' <> pc ->
829-
incr update_branch;
830-
pc', []
831-
| Some _ | None ->
832-
SBT.add t sb pc;
833-
Addr.Hashtbl.add seen_pc pc ();
834-
pc, [])
826+
if List.compare_length_with block.body ~len:7 <= 0
827+
then (
828+
let sb = Simple_block.make block in
829+
match SBT.find_opt (Lazy.force t) sb with
830+
| Some pc' when pc' <> pc ->
831+
incr update_branch;
832+
pc', []
833+
| Some _ | None ->
834+
SBT.add (Lazy.force t) sb pc;
835+
seen_pc := IntSet.add pc !seen_pc;
836+
pc, [])
837+
else cont
835838
| cont -> cont) ))
836839
| cont -> cont
837840

0 commit comments

Comments
 (0)