Box ast::path values
It seems inefficient to copy them around. Let's measure whether that's actually > the case
This commit is contained in:
parent
586a685eec
commit
b40c6773c2
20 changed files with 102 additions and 103 deletions
|
|
@ -16,8 +16,7 @@ tag copied { not_allowed; copied; not_copied; }
|
|||
tag invalid_reason { overwritten; val_taken; }
|
||||
type invalid = {reason: invalid_reason,
|
||||
node_id: node_id,
|
||||
sp: span, path:
|
||||
ast::path};
|
||||
sp: span, path: @ast::path};
|
||||
|
||||
tag unsafe_ty { contains(ty::t); mut_contains(ty::t); }
|
||||
|
||||
|
|
@ -374,7 +373,7 @@ fn check_for(cx: ctx, local: @ast::local, seq: @ast::expr, blk: ast::blk,
|
|||
visit::visit_block(blk, {bs: new_bs with sc}, v);
|
||||
}
|
||||
|
||||
fn check_var(cx: ctx, ex: @ast::expr, p: ast::path, id: ast::node_id,
|
||||
fn check_var(cx: ctx, ex: @ast::expr, p: @ast::path, id: ast::node_id,
|
||||
assign: bool, sc: scope) {
|
||||
let def = cx.tcx.def_map.get(id);
|
||||
if !def_is_local(def, false) { ret; }
|
||||
|
|
@ -445,7 +444,7 @@ fn check_loop(cx: ctx, sc: scope, checker: block()) {
|
|||
*sc.invalid = new_invalid;
|
||||
}
|
||||
|
||||
fn test_scope(cx: ctx, sc: scope, b: binding, p: ast::path) {
|
||||
fn test_scope(cx: ctx, sc: scope, b: binding, p: @ast::path) {
|
||||
let prob = find_invalid(b.node_id, *sc.invalid);
|
||||
alt b.root_var {
|
||||
some(dn) {
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ tag scope {
|
|||
type scopes = list<scope>;
|
||||
|
||||
tag import_state {
|
||||
todo(ast::node_id, ast::ident, [ast::ident], codemap::span, scopes);
|
||||
todo(ast::node_id, ast::ident, @[ast::ident], codemap::span, scopes);
|
||||
resolving(span);
|
||||
resolved(option::t<def>, /* value */
|
||||
option::t<def>, /* type */
|
||||
|
|
@ -172,7 +172,7 @@ fn map_crate(e: @env, c: @ast::crate) {
|
|||
for ident in idents {
|
||||
e.imports.insert(ident.node.id,
|
||||
todo(ident.node.id, ident.node.name,
|
||||
mod_path + [ident.node.name],
|
||||
@(*mod_path + [ident.node.name]),
|
||||
ident.span, sc));
|
||||
}
|
||||
}
|
||||
|
|
@ -214,7 +214,7 @@ fn map_crate(e: @env, c: @ast::crate) {
|
|||
alt vi.node {
|
||||
//if it really is a glob import, that is
|
||||
ast::view_item_import_glob(path, _) {
|
||||
let imp = follow_import(*e, sc, path, vi.span);
|
||||
let imp = follow_import(*e, sc, *path, vi.span);
|
||||
if option::is_some(imp) {
|
||||
let glob = {def: option::get(imp), item: vi};;
|
||||
alt list::head(sc) {
|
||||
|
|
@ -243,7 +243,7 @@ fn resolve_imports(e: env) {
|
|||
e.imports.values {|v|
|
||||
alt v {
|
||||
todo(node_id, name, path, span, scopes) {
|
||||
resolve_import(e, local_def(node_id), name, path, span, scopes);
|
||||
resolve_import(e, local_def(node_id), name, *path, span, scopes);
|
||||
}
|
||||
resolved(_, _, _, _, _) { }
|
||||
}
|
||||
|
|
@ -304,7 +304,7 @@ fn resolve_names(e: @env, c: @ast::crate) {
|
|||
_ { }
|
||||
}
|
||||
}
|
||||
fn walk_constr(e: @env, p: ast::path, sp: span, id: node_id, sc: scopes,
|
||||
fn walk_constr(e: @env, p: @ast::path, sp: span, id: node_id, sc: scopes,
|
||||
_v: vt<scopes>) {
|
||||
maybe_insert(e, id, lookup_path_strict(*e, sc, sp, p.node, ns_value));
|
||||
}
|
||||
|
|
@ -966,7 +966,7 @@ fn found_view_item(e: env, vi: @ast::view_item) -> option::t<def> {
|
|||
fn lookup_import(e: env, defid: def_id, ns: namespace) -> option::t<def> {
|
||||
alt e.imports.get(defid.node) {
|
||||
todo(node_id, name, path, span, scopes) {
|
||||
resolve_import(e, local_def(node_id), name, path, span, scopes);
|
||||
resolve_import(e, local_def(node_id), name, *path, span, scopes);
|
||||
ret lookup_import(e, defid, ns);
|
||||
}
|
||||
resolving(sp) {
|
||||
|
|
|
|||
|
|
@ -2967,7 +2967,7 @@ fn trans_local_var(cx: @block_ctxt, def: ast::def) -> lval_result {
|
|||
}
|
||||
}
|
||||
|
||||
fn trans_path(cx: @block_ctxt, p: ast::path, id: ast::node_id)
|
||||
fn trans_path(cx: @block_ctxt, p: @ast::path, id: ast::node_id)
|
||||
-> lval_maybe_callee {
|
||||
ret trans_var(cx, p.span, bcx_tcx(cx).def_map.get(id), id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ tag constraint {
|
|||
|
||||
// FIXME: really only want it to be mutable during collect_locals.
|
||||
// freeze it after that.
|
||||
cpred(path, @mutable [pred_args]);
|
||||
cpred(@path, @mutable [pred_args]);
|
||||
}
|
||||
|
||||
// An ninit variant has a node_id because it refers to a local var.
|
||||
|
|
@ -204,7 +204,7 @@ tag constraint {
|
|||
// and give ninit a constraint saying it's local.
|
||||
tag tsconstr {
|
||||
ninit(node_id, ident);
|
||||
npred(path, def_id, [@constr_arg_use]);
|
||||
npred(@path, def_id, [@constr_arg_use]);
|
||||
}
|
||||
|
||||
type sp_constr = spanned<tsconstr>;
|
||||
|
|
@ -773,7 +773,7 @@ fn replace(subst: subst, d: pred_args) -> [constr_arg_general_<inst>] {
|
|||
ret rslt;
|
||||
}
|
||||
|
||||
fn path_to_ident(cx: ty::ctxt, p: path) -> ident {
|
||||
fn path_to_ident(cx: ty::ctxt, p: @path) -> ident {
|
||||
alt vec::last(p.node.idents) {
|
||||
none. { cx.sess.span_fatal(p.span, "Malformed path"); }
|
||||
some(i) { ret i; }
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk,
|
|||
}
|
||||
|
||||
fn gen_if_local(fcx: fn_ctxt, lhs: @expr, rhs: @expr, larger_id: node_id,
|
||||
new_var: node_id, pth: path) {
|
||||
new_var: node_id, pth: @path) {
|
||||
alt node_id_to_def(fcx.ccx, new_var) {
|
||||
some(d) {
|
||||
alt d {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ fn forbid_upvar(fcx: fn_ctxt, rhs_id: node_id, sp: span, t: oper_type) {
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_move_or_copy(fcx: fn_ctxt, post: poststate, rhs_path: path,
|
||||
fn handle_move_or_copy(fcx: fn_ctxt, post: poststate, rhs_path: @path,
|
||||
rhs_id: node_id, instlhs: inst, init_op: init_op) {
|
||||
forbid_upvar(fcx, rhs_id, rhs_path.span, op_to_oper_ty(init_op));
|
||||
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ tag sty {
|
|||
// In the middle end, constraints have a def_id attached, referring
|
||||
// to the definition of the operator in the constraint.
|
||||
type constr_general<ARG> = spanned<constr_general_<ARG, def_id>>;
|
||||
type type_constr = constr_general<path>;
|
||||
type type_constr = constr_general<@path>;
|
||||
type constr = constr_general<uint>;
|
||||
|
||||
// Data structures used in type unification
|
||||
|
|
|
|||
|
|
@ -130,8 +130,9 @@ fn ty_param_kinds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) ->
|
|||
|
||||
// Instantiates the given path, which must refer to an item with the given
|
||||
// number of type parameters and type.
|
||||
fn instantiate_path(fcx: @fn_ctxt, pth: ast::path, tpt: ty_param_kinds_and_ty,
|
||||
sp: span) -> ty_param_substs_opt_and_ty {
|
||||
fn instantiate_path(fcx: @fn_ctxt, pth: @ast::path,
|
||||
tpt: ty_param_kinds_and_ty, sp: span)
|
||||
-> ty_param_substs_opt_and_ty {
|
||||
let ty_param_count = vec::len(tpt.kinds);
|
||||
let bind_result =
|
||||
bind_params_in_type(sp, fcx.ccx.tcx, bind next_ty_var_id(fcx), tpt.ty,
|
||||
|
|
@ -2586,7 +2587,7 @@ fn check_constraints(fcx: @fn_ctxt, cs: [@ast::constr], args: [ast::arg]) {
|
|||
ast::def_arg(local_def(args[i].id),
|
||||
args[i].mode));
|
||||
{id: arg_occ_node_id,
|
||||
node: ast::expr_path(respan(a.span, p)),
|
||||
node: ast::expr_path(@respan(a.span, p)),
|
||||
span: a.span}
|
||||
} else {
|
||||
fcx.ccx.tcx.sess.span_bug(a.span,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue