From 7295a6da92ac4bfcbc714848bd611dae54df0b67 Mon Sep 17 00:00:00 2001 From: Philipp Brüschweiler Date: Thu, 27 Jun 2013 15:04:22 +0200 Subject: Remove many shared pointers Mostly just low-haning fruit, i.e. function arguments that were @ even though & would work just as well. Reduces librustc.so size by 200k when compiling without -O, by 100k when compiling with -O. --- src/libsyntax/ast_map.rs | 2 +- src/libsyntax/ast_util.rs | 6 +++--- src/libsyntax/ext/deriving/cmp/totaleq.rs | 2 -- src/libsyntax/ext/expand.rs | 4 ++-- src/libsyntax/visit.rs | 28 ++++++++++++++-------------- 5 files changed, 20 insertions(+), 22 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index d381f934d9a..3abbe397054 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -124,7 +124,7 @@ pub fn mk_ast_map_visitor() -> vt { }); } -pub fn map_crate(diag: @span_handler, c: @crate) -> map { +pub fn map_crate(diag: @span_handler, c: &crate) -> map { let cx = @mut Ctx { map: @mut HashMap::new(), path: ~[], diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index fd8fbc72e57..9ba7cb3c818 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -565,11 +565,11 @@ pub fn walk_pat(pat: @pat, it: &fn(@pat) -> bool) -> bool { } pub trait EachViewItem { - pub fn each_view_item(&self, f: @fn(@ast::view_item) -> bool) -> bool; + pub fn each_view_item(&self, f: @fn(&ast::view_item) -> bool) -> bool; } impl EachViewItem for ast::crate { - fn each_view_item(&self, f: @fn(@ast::view_item) -> bool) -> bool { + fn each_view_item(&self, f: @fn(&ast::view_item) -> bool) -> bool { let broke = @mut false; let vtor: visit::vt<()> = visit::mk_simple_visitor(@visit::SimpleVisitor { visit_view_item: |vi| { *broke = f(vi); }, ..*visit::default_simple_visitor() @@ -579,7 +579,7 @@ impl EachViewItem for ast::crate { } } -pub fn view_path_id(p: @view_path) -> node_id { +pub fn view_path_id(p: &view_path) -> node_id { match p.node { view_path_simple(_, _, id) | view_path_glob(_, id) | diff --git a/src/libsyntax/ext/deriving/cmp/totaleq.rs b/src/libsyntax/ext/deriving/cmp/totaleq.rs index ccfb34a3a2f..70ac4d3d4c1 100644 --- a/src/libsyntax/ext/deriving/cmp/totaleq.rs +++ b/src/libsyntax/ext/deriving/cmp/totaleq.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::prelude::*; - use ast::{meta_item, item, expr}; use codemap::span; use ext::base::ExtCtxt; diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 7fc784320ac..15f915ba4d8 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -644,7 +644,7 @@ pub fn core_macros() -> @str { } pub fn expand_crate(parse_sess: @mut parse::ParseSess, - cfg: ast::crate_cfg, c: @crate) -> @crate { + cfg: ast::crate_cfg, c: &crate) -> @crate { // adding *another* layer of indirection here so that the block // visitor can swap out one exts table for another for the duration // of the block. The cleaner alternative would be to thread the @@ -695,7 +695,7 @@ pub fn expand_crate(parse_sess: @mut parse::ParseSess, // as it registers all the core macros as expanders. f.fold_item(cm); - @f.fold_crate(&*c) + @f.fold_crate(c) } // given a function from idents to idents, produce diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index f0a993dbb94..9fcffc11013 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -39,7 +39,7 @@ pub enum fn_kind<'self> { // fn foo(&self) fk_method(ident, &'self Generics, &'self method), - // fn@(x, y) { ... } + // @fn(x, y) { ... } fk_anon(ast::Sigil), // |x, y| ... @@ -129,9 +129,9 @@ pub fn visit_mod(m: &_mod, _sp: span, _id: node_id, (e, v): (E, vt)) for m.items.iter().advance |i| { (v.visit_item)(*i, (copy e, v)); } } -pub fn visit_view_item(_vi: @view_item, (_e, _v): (E, vt)) { } +pub fn visit_view_item(_vi: &view_item, (_e, _v): (E, vt)) { } -pub fn visit_local(loc: @local, (e, v): (E, vt)) { +pub fn visit_local(loc: &local, (e, v): (E, vt)) { (v.visit_pat)(loc.node.pat, (copy e, v)); (v.visit_ty)(loc.node.ty, (copy e, v)); match loc.node.init { @@ -140,11 +140,11 @@ pub fn visit_local(loc: @local, (e, v): (E, vt)) { } } -fn visit_trait_ref(tref: @ast::trait_ref, (e, v): (E, vt)) { +fn visit_trait_ref(tref: &ast::trait_ref, (e, v): (E, vt)) { visit_path(tref.path, (e, v)); } -pub fn visit_item(i: @item, (e, v): (E, vt)) { +pub fn visit_item(i: &item, (e, v): (E, vt)) { match i.node { item_static(t, _, ex) => { (v.visit_ty)(t, (copy e, v)); @@ -230,9 +230,9 @@ pub fn visit_enum_def(enum_definition: &ast::enum_def, } } -pub fn skip_ty(_t: @Ty, (_e,_v): (E, vt)) {} +pub fn skip_ty(_t: &Ty, (_e,_v): (E, vt)) {} -pub fn visit_ty(t: @Ty, (e, v): (E, vt)) { +pub fn visit_ty(t: &Ty, (e, v): (E, vt)) { match t.node { ty_box(mt) | ty_uniq(mt) | ty_vec(mt) | ty_ptr(mt) | ty_rptr(_, mt) => { @@ -268,11 +268,11 @@ pub fn visit_ty(t: @Ty, (e, v): (E, vt)) { } } -pub fn visit_path(p: @Path, (e, v): (E, vt)) { +pub fn visit_path(p: &Path, (e, v): (E, vt)) { for p.types.iter().advance |tp| { (v.visit_ty)(*tp, (copy e, v)); } } -pub fn visit_pat(p: @pat, (e, v): (E, vt)) { +pub fn visit_pat(p: &pat, (e, v): (E, vt)) { match p.node { pat_enum(path, ref children) => { visit_path(path, (copy e, v)); @@ -322,7 +322,7 @@ pub fn visit_pat(p: @pat, (e, v): (E, vt)) { } } -pub fn visit_foreign_item(ni: @foreign_item, (e, v): (E, vt)) { +pub fn visit_foreign_item(ni: &foreign_item, (e, v): (E, vt)) { match ni.node { foreign_item_fn(ref fd, _, ref generics) => { visit_fn_decl(fd, (copy e, v)); @@ -410,11 +410,11 @@ pub fn visit_struct_def( } } -pub fn visit_struct_field(sf: @struct_field, (e, v): (E, vt)) { +pub fn visit_struct_field(sf: &struct_field, (e, v): (E, vt)) { (v.visit_ty)(sf.node.ty, (e, v)); } -pub fn visit_struct_method(m: @method, (e, v): (E, vt)) { +pub fn visit_struct_method(m: &method, (e, v): (E, vt)) { visit_method_helper(m, (e, v)); } @@ -428,7 +428,7 @@ pub fn visit_block(b: &blk, (e, v): (E, vt)) { visit_expr_opt(b.node.expr, (e, v)); } -pub fn visit_stmt(s: @stmt, (e, v): (E, vt)) { +pub fn visit_stmt(s: &stmt, (e, v): (E, vt)) { match s.node { stmt_decl(d, _) => (v.visit_decl)(d, (e, v)), stmt_expr(ex, _) => (v.visit_expr)(ex, (e, v)), @@ -437,7 +437,7 @@ pub fn visit_stmt(s: @stmt, (e, v): (E, vt)) { } } -pub fn visit_decl(d: @decl, (e, v): (E, vt)) { +pub fn visit_decl(d: &decl, (e, v): (E, vt)) { match d.node { decl_local(ref loc) => (v.visit_local)(*loc, (e, v)), decl_item(it) => (v.visit_item)(it, (e, v)) -- cgit 1.4.1-3-g733a5