@@ -227,7 +227,8 @@ type ctxt =
227
227
iface_method_cache : hashmap < def_id , @[ method ] > ,
228
228
ty_param_bounds : hashmap < ast:: node_id , param_bounds > ,
229
229
inferred_modes : hashmap < ast:: node_id , ast:: mode > ,
230
- borrowings : hashmap < ast:: node_id , ( ) > } ;
230
+ borrowings : hashmap < ast:: node_id , ( ) > ,
231
+ normalized_cache : hashmap < t , t > } ;
231
232
232
233
type t_box = @{ struct : sty ,
233
234
id : uint ,
@@ -461,7 +462,8 @@ fn mk_ctxt(s: session::session, dm: resolve::def_map, amap: ast_map::map,
461
462
iface_method_cache: new_def_hash ( ) ,
462
463
ty_param_bounds: map:: int_hash ( ) ,
463
464
inferred_modes: map:: int_hash ( ) ,
464
- borrowings: map:: int_hash ( ) }
465
+ borrowings: map:: int_hash ( ) ,
466
+ normalized_cache: new_ty_hash ( ) }
465
467
}
466
468
467
469
@@ -2680,6 +2682,11 @@ fn ty_params_to_tys(tcx: ty::ctxt, tps: [ast::ty_param]) -> [t] {
2680
2682
Returns an equivalent type with all the typedefs and self regions removed.
2681
2683
"]
2682
2684
fn normalize_ty( cx: ctxt, t: t) -> t {
2685
+ alt cx. normalized_cache. find( t) {
2686
+ some( t) { ret t; }
2687
+ none { }
2688
+ }
2689
+
2683
2690
let t = alt get( t) . struct {
2684
2691
ty_enum( did, r) {
2685
2692
alt r. self_r {
@@ -2698,7 +2705,9 @@ fn normalize_ty(cx: ctxt, t: t) -> t {
2698
2705
let t = mk_t( cx, mach_sty( cx. sess. targ_cfg, t) ) ;
2699
2706
2700
2707
let sty = fold_sty( get( t) . struct ) { |t| normalize_ty( cx, t) } ;
2701
- mk_t( cx, sty)
2708
+ let t_norm = mk_t( cx, sty) ;
2709
+ cx. normalized_cache. insert( t, t_norm) ;
2710
+ ret t_norm;
2702
2711
}
2703
2712
2704
2713
// Local Variables:
0 commit comments