Skip to content

Commit 816b0ac

Browse files
committed
Box ty_param_bounds_and_ty
It contains a vector, which shouldn't be copied all the time.
1 parent 2ed1005 commit 816b0ac

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

src/comp/metadata/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ fn get_type(data: @[u8], def: ast::def_id, tcx: ty::ctxt,
213213
let tp_bounds = if family_has_type_params(item_family(item)) {
214214
item_ty_param_bounds(item, this_cnum, tcx, extres)
215215
} else { [] };
216-
ret {bounds: tp_bounds, ty: t};
216+
ret @{bounds: tp_bounds, ty: t};
217217
}
218218

219219
fn get_type_param_count(data: @[u8], id: ast::node_id) -> uint {

src/comp/middle/trans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2731,7 +2731,7 @@ fn trans_var(cx: @block_ctxt, sp: span, def: ast::def, id: ast::node_id)
27312731
ret lval_no_env(cx, ccx.consts.get(did.node), owned);
27322732
} else {
27332733
let tp = ty::node_id_to_monotype(ccx.tcx, id);
2734-
let val = trans_external_path(cx, did, {bounds: [], ty: tp});
2734+
let val = trans_external_path(cx, did, @{bounds: [], ty: tp});
27352735
ret lval_no_env(cx, load_if_immediate(cx, val, tp), owned_imm);
27362736
}
27372737
}

src/comp/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ fn param_bounds_to_kind(bounds: @[param_bound]) -> kind {
322322
kind
323323
}
324324

325-
type ty_param_bounds_and_ty = {bounds: [@[param_bound]], ty: t};
325+
type ty_param_bounds_and_ty = @{bounds: [@[param_bound]], ty: t};
326326

327327
type type_cache = hashmap<ast::def_id, ty_param_bounds_and_ty>;
328328

src/comp/middle/typeck.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,22 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) ->
7676
ast::def_arg(id, _) {
7777
assert (fcx.locals.contains_key(id.node));
7878
let typ = ty::mk_var(fcx.ccx.tcx, lookup_local(fcx, sp, id.node));
79-
ret {bounds: [], ty: typ};
79+
ret @{bounds: [], ty: typ};
8080
}
8181
ast::def_local(id, _) {
8282
assert (fcx.locals.contains_key(id.node));
8383
let typ = ty::mk_var(fcx.ccx.tcx, lookup_local(fcx, sp, id.node));
84-
ret {bounds: [], ty: typ};
84+
ret @{bounds: [], ty: typ};
8585
}
8686
ast::def_obj_field(id, _) {
8787
assert (fcx.locals.contains_key(id.node));
8888
let typ = ty::mk_var(fcx.ccx.tcx, lookup_local(fcx, sp, id.node));
89-
ret {bounds: [], ty: typ};
89+
ret @{bounds: [], ty: typ};
9090
}
9191
ast::def_self(id) {
9292
alt get_self_info(fcx.ccx) {
9393
some(self_obj(_, obj_t)) | some(self_impl(obj_t)) {
94-
ret {bounds: [], ty: obj_t};
94+
ret @{bounds: [], ty: obj_t};
9595
}
9696
}
9797
}
@@ -102,12 +102,12 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) ->
102102
ast::def_binding(id) {
103103
assert (fcx.locals.contains_key(id.node));
104104
let typ = ty::mk_var(fcx.ccx.tcx, lookup_local(fcx, sp, id.node));
105-
ret {bounds: [], ty: typ};
105+
ret @{bounds: [], ty: typ};
106106
}
107107
ast::def_mod(_) {
108108
// Hopefully part of a path.
109109
// TODO: return a type that's more poisonous, perhaps?
110-
ret {bounds: [], ty: ty::mk_nil(fcx.ccx.tcx)};
110+
ret @{bounds: [], ty: ty::mk_nil(fcx.ccx.tcx)};
111111
}
112112
ast::def_ty(_) {
113113
fcx.ccx.tcx.sess.span_fatal(sp, "expected value but found type");
@@ -382,7 +382,7 @@ fn ty_of_item(tcx: ty::ctxt, mode: mode, it: @ast::item)
382382
alt it.node {
383383
ast::item_const(t, _) {
384384
let typ = ast_ty_to_ty(tcx, mode, t);
385-
let tpt = {bounds: [], ty: typ};
385+
let tpt = @{bounds: [], ty: typ};
386386
tcx.tcache.insert(local_def(it.id), tpt);
387387
ret tpt;
388388
}
@@ -401,7 +401,7 @@ fn ty_of_item(tcx: ty::ctxt, mode: mode, it: @ast::item)
401401
}
402402
// Tell ast_ty_to_ty() that we want to perform a recursive
403403
// call to resolve any named types.
404-
let tpt = {bounds: ty_param_bounds(tcx, mode, tps),
404+
let tpt = @{bounds: ty_param_bounds(tcx, mode, tps),
405405
ty: ty::mk_named(tcx, ast_ty_to_ty(tcx, mode, t),
406406
@it.ident)};
407407
tcx.tcache.insert(local_def(it.id), tpt);
@@ -413,7 +413,7 @@ fn ty_of_item(tcx: ty::ctxt, mode: mode, it: @ast::item)
413413
let t = ty::mk_named(tcx, ty::mk_res(tcx, local_def(it.id), t_arg.ty,
414414
params),
415415
@it.ident);
416-
let t_res = {bounds: bounds, ty: t};
416+
let t_res = @{bounds: bounds, ty: t};
417417
tcx.tcache.insert(local_def(it.id), t_res);
418418
ret t_res;
419419
}
@@ -422,7 +422,7 @@ fn ty_of_item(tcx: ty::ctxt, mode: mode, it: @ast::item)
422422
let {bounds, params} = mk_ty_params(tcx, tps);
423423
let t = ty::mk_named(tcx, ty::mk_tag(tcx, local_def(it.id), params),
424424
@it.ident);
425-
let tpt = {bounds: bounds, ty: t};
425+
let tpt = @{bounds: bounds, ty: t};
426426
tcx.tcache.insert(local_def(it.id), tpt);
427427
ret tpt;
428428
}
@@ -431,7 +431,7 @@ fn ty_of_item(tcx: ty::ctxt, mode: mode, it: @ast::item)
431431
let t = ty::mk_named(tcx, ty::mk_iface(tcx, local_def(it.id),
432432
params),
433433
@it.ident);
434-
let tpt = {bounds: bounds, ty: t};
434+
let tpt = @{bounds: bounds, ty: t};
435435
tcx.tcache.insert(local_def(it.id), tpt);
436436
ty::store_iface_methods(tcx, it.id, @vec::map(ms, {|m|
437437
ty_of_ty_method(tcx, m_collect, m)
@@ -455,7 +455,7 @@ fn ty_of_native_item(tcx: ty::ctxt, mode: mode, it: @ast::native_item)
455455
none. { }
456456
}
457457
let t = ty::mk_native(tcx, ast_util::local_def(it.id));
458-
let tpt = {bounds: [], ty: t};
458+
let tpt = @{bounds: [], ty: t};
459459
tcx.tcache.insert(local_def(it.id), tpt);
460460
ret tpt;
461461
}
@@ -480,7 +480,7 @@ fn ty_of_fn_decl(tcx: ty::ctxt, mode: mode, decl: ast::fn_decl) -> ty::fn_ty {
480480
fn ty_of_fn(tcx: ty::ctxt, mode: mode, decl: ast::fn_decl,
481481
ty_params: [ast::ty_param], def_id: ast::def_id)
482482
-> ty::ty_param_bounds_and_ty {
483-
let tpt = {bounds: ty_param_bounds(tcx, mode, ty_params),
483+
let tpt = @{bounds: ty_param_bounds(tcx, mode, ty_params),
484484
ty: ty::mk_fn(tcx, ty_of_fn_decl(tcx, mode, decl))};
485485
tcx.tcache.insert(def_id, tpt);
486486
ret tpt;
@@ -493,7 +493,7 @@ fn ty_of_native_fn_decl(tcx: ty::ctxt, mode: mode, decl: ast::fn_decl,
493493
let output_ty = ast_ty_to_ty(tcx, mode, decl.output);
494494

495495
let t_fn = ty::mk_native_fn(tcx, input_tys, output_ty);
496-
let tpt = {bounds: bounds, ty: t_fn};
496+
let tpt = @{bounds: bounds, ty: t_fn};
497497
tcx.tcache.insert(def_id, tpt);
498498
ret tpt;
499499
}
@@ -537,7 +537,7 @@ fn ty_of_obj(tcx: ty::ctxt, mode: mode, id: ast::ident, ob: ast::_obj,
537537
let methods = vec::map(ob.methods, {|m| ty_of_method(tcx, mode, m)});
538538
let t_obj = ty::mk_named(tcx, ty::mk_obj(tcx, ty::sort_methods(methods)),
539539
@id);
540-
ret {bounds: bounds, ty: t_obj};
540+
ret @{bounds: bounds, ty: t_obj};
541541
}
542542
fn ty_of_obj_ctor(tcx: ty::ctxt, mode: mode, id: ast::ident, ob: ast::_obj,
543543
ctor_id: ast::node_id, ty_params: [ast::ty_param])
@@ -551,7 +551,7 @@ fn ty_of_obj_ctor(tcx: ty::ctxt, mode: mode, id: ast::ident, ob: ast::_obj,
551551
let t_fn = ty::mk_fn(tcx, {proto: ast::proto_shared(ast::sugar_normal),
552552
inputs: t_inputs, output: t_obj.ty,
553553
ret_style: ast::return_val, constraints: []});
554-
let tpt = {bounds: ty_param_bounds(tcx, mode, ty_params), ty: t_fn};
554+
let tpt = @{bounds: ty_param_bounds(tcx, mode, ty_params), ty: t_fn};
555555
tcx.tcache.insert(local_def(ctor_id), tpt);
556556
ret tpt;
557557
}
@@ -672,7 +672,7 @@ mod collect {
672672
inputs: args, output: tag_ty,
673673
ret_style: ast::return_val, constraints: []})
674674
};
675-
let tpt = {bounds: ty_param_bounds(cx.tcx, m_collect, ty_params),
675+
let tpt = @{bounds: ty_param_bounds(cx.tcx, m_collect, ty_params),
676676
ty: result_ty};
677677
cx.tcx.tcache.insert(local_def(variant.node.id), tpt);
678678
write::ty_only(cx.tcx, variant.node.id, result_ty);
@@ -693,7 +693,7 @@ mod collect {
693693
let bounds = ty_param_bounds(cx.tcx, m_collect, m.tps);
694694
let ty = ty::mk_fn(cx.tcx, ty_of_fn_decl(cx.tcx, m_collect,
695695
m.decl));
696-
cx.tcx.tcache.insert(local_def(m.id), {bounds: bounds,
696+
cx.tcx.tcache.insert(local_def(m.id), @{bounds: bounds,
697697
ty: ty});
698698
write::ty_only(cx.tcx, m.id, ty);
699699
}
@@ -751,7 +751,7 @@ mod collect {
751751
write::ty_only(cx.tcx, it.id, t_res);
752752
write::ty_only(cx.tcx, ctor_id, t_ctor);
753753
cx.tcx.tcache.insert(local_def(ctor_id),
754-
{bounds: bounds,
754+
@{bounds: bounds,
755755
ty: t_ctor});
756756
write::ty_only(cx.tcx, dtor_id, t_dtor);
757757
}

0 commit comments

Comments
 (0)