Skip to content

Commit db451b5

Browse files
mshinwellpoechsel
authored andcommitted
flambda-backend: Speedups in Asmlink (#8)
1 parent 2fe489d commit db451b5

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

utils/consistbl.ml

+7-14
Original file line numberDiff line numberDiff line change
@@ -60,25 +60,18 @@ end) = struct
6060

6161
let source tbl name = snd (Module_name.Tbl.find tbl name)
6262

63+
let find t name =
64+
match Module_name.Tbl.find t name with
65+
| exception Not_found -> None
66+
| (crc, _) -> Some crc
67+
6368
let extract l tbl =
6469
let l = List.sort_uniq Module_name.compare l in
65-
List.fold_left
66-
(fun assc name ->
67-
try
68-
let (crc, _) = Module_name.Tbl.find tbl name in
69-
(name, Some crc) :: assc
70-
with Not_found ->
71-
(name, None) :: assc)
72-
[] l
70+
List.fold_left (fun assc name -> (name, find tbl name) :: assc) [] l
7371

7472
let extract_map mod_names tbl =
7573
Module_name.Set.fold
76-
(fun name result ->
77-
try
78-
let (crc, _) = Module_name.Tbl.find tbl name in
79-
Module_name.Map.add name (Some crc) result
80-
with Not_found ->
81-
Module_name.Map.add name None result)
74+
(fun name result -> Module_name.Map.add name (find tbl name) result)
8275
mod_names
8376
Module_name.Map.empty
8477

utils/consistbl.mli

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ end) : sig
5757
if the latter has an associated CRC in [tbl].
5858
Raise [Not_found] otherwise. *)
5959

60+
val find: t -> Module_name.t -> Digest.t option
61+
6062
val extract: Module_name.t list -> t -> (Module_name.t * Digest.t option) list
6163
(* [extract tbl names] returns an associative list mapping each string
6264
in [names] to the CRC associated with it in [tbl]. If no CRC is

0 commit comments

Comments
 (0)