@@ -217,6 +217,7 @@ type ctxt =
217
217
creader_cache rcache,
218
218
hashmap[ t, str] short_names_cache ,
219
219
hashmap[ t, bool] has_pointer_cache ,
220
+ hashmap[ t, bool] owns_heap_mem_cache ,
220
221
hashmap[ @ast:: ty, option:: t[ t] ] ast_ty_to_ty_cache ) ;
221
222
222
223
type ty_ctxt = ctxt ;
@@ -413,6 +414,8 @@ fn mk_ctxt(session::session s, resolve::def_map dm, constr_table cs,
413
414
str] ( ty:: hash_ty, ty:: eq_ty) ,
414
415
has_pointer_cache=map:: mk_hashmap[ ty:: t,
415
416
bool] ( ty:: hash_ty, ty:: eq_ty) ,
417
+ owns_heap_mem_cache=map:: mk_hashmap[ ty:: t,
418
+ bool] ( ty:: hash_ty, ty:: eq_ty) ,
416
419
ast_ty_to_ty_cache=map:: mk_hashmap[ @ast:: ty,
417
420
option:: t[ t] ] ( ast:: hash_ty,
418
421
ast:: eq_ty) ) ;
@@ -1172,6 +1175,11 @@ fn type_is_signed(&ctxt cx, &t ty) -> bool {
1172
1175
}
1173
1176
1174
1177
fn type_owns_heap_mem( & ctxt cx, & t ty) -> bool {
1178
+ alt ( cx. owns_heap_mem_cache. find( ty) ) {
1179
+ case ( some( ?result) ) { ret result; }
1180
+ case ( none) { /* fall through */ }
1181
+ }
1182
+
1175
1183
auto result = false;
1176
1184
alt ( struct ( cx, ty) ) {
1177
1185
case ( ty_ivec( _) ) { result = true; }
@@ -1228,6 +1236,8 @@ fn type_owns_heap_mem(&ctxt cx, &t ty) -> bool {
1228
1236
case ( ty_var( _) ) { fail "ty_var in type_owns_heap_mem"; }
1229
1237
case ( ty_param( _) ) { result = false; }
1230
1238
}
1239
+
1240
+ cx. owns_heap_mem_cache. insert( ty, result) ;
1231
1241
ret result;
1232
1242
}
1233
1243
0 commit comments