Skip to content

Commit 5a7cdc5

Browse files
committed
---
yaml --- r: 755 b: refs/heads/master c: 81e791d h: refs/heads/master i: 753: ce2e318 751: 7e4213b v: v3
1 parent 2257f68 commit 5a7cdc5

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 97a6b0935bad25833d2b48352a3f4212c26c9898
2+
refs/heads/master: 81e791d7b981bfb815d99832d657d48850e8e0aa

trunk/src/boot/me/resolve.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,9 @@ let process_crate
869869
(Hashtbl.find cx.ctxt_all_item_names n)
870870
end
871871
cx.ctxt_node_referenced;
872-
end
872+
end;
873+
(* Post-resolve, we can establish a tag cache. *)
874+
cx.ctxt_tag_cache <- Some (Hashtbl.create 0);
873875
;;
874876

875877
(*

trunk/src/boot/me/semant.ml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ type ctxt =
194194
ctxt_type_is_structured_cache: (Ast.ty,bool) Hashtbl.t;
195195
ctxt_type_contains_chan_cache: (Ast.ty,bool) Hashtbl.t;
196196
ctxt_n_used_type_parameters_cache: (Ast.ty,int) Hashtbl.t;
197+
mutable ctxt_tag_cache:
198+
((Ast.ty_tag option * Ast.ty_tag * int,
199+
Ast.ty_tup) Hashtbl.t) option;
197200
}
198201
;;
199202

@@ -290,6 +293,7 @@ let new_ctxt sess abi crate =
290293
ctxt_type_is_structured_cache = Hashtbl.create 0;
291294
ctxt_type_contains_chan_cache = Hashtbl.create 0;
292295
ctxt_n_used_type_parameters_cache = Hashtbl.create 0;
296+
ctxt_tag_cache = None;
293297
}
294298
;;
295299

@@ -797,13 +801,18 @@ let get_nth_tag_tup_full
797801
(ttag:Ast.ty_tag)
798802
(i:int)
799803
: Ast.ty_tup =
800-
let tinfo = Hashtbl.find cx.ctxt_all_tag_info ttag.Ast.tag_id in
801-
let (_, node_id, ttup) = Hashtbl.find tinfo.tag_nums i in
802-
let ctor = get_item cx node_id in
803-
let params = Array.map (fun p -> p.node) ctor.Ast.decl_params in
804-
Array.map
805-
(fun ty -> rebuilder src_tag ty params ttag.Ast.tag_args)
806-
ttup
804+
let calculate _ =
805+
let tinfo = Hashtbl.find cx.ctxt_all_tag_info ttag.Ast.tag_id in
806+
let (_, node_id, ttup) = Hashtbl.find tinfo.tag_nums i in
807+
let ctor = get_item cx node_id in
808+
let params = Array.map (fun p -> p.node) ctor.Ast.decl_params in
809+
Array.map
810+
(fun ty -> rebuilder src_tag ty params ttag.Ast.tag_args)
811+
ttup
812+
in
813+
match cx.ctxt_tag_cache with
814+
None -> calculate()
815+
| Some cache -> htab_search_or_add cache (src_tag,ttag,i) calculate
807816
;;
808817

809818
let rec fold_ty_full

0 commit comments

Comments
 (0)