diff options
| author | Philipp Brüschweiler <blei42@gmail.com> | 2013-06-27 15:04:22 +0200 |
|---|---|---|
| committer | Philipp Brüschweiler <blei42@gmail.com> | 2013-06-27 15:06:19 +0200 |
| commit | 7295a6da92ac4bfcbc714848bd611dae54df0b67 (patch) | |
| tree | 20cb2e86cc5b98024c3d2a9b87fd8ba6289979fb /src/libsyntax | |
| parent | 0bad3e62b48a172389833520fad375fecc3f9be7 (diff) | |
| download | rust-7295a6da92ac4bfcbc714848bd611dae54df0b67.tar.gz rust-7295a6da92ac4bfcbc714848bd611dae54df0b67.zip | |
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.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast_map.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/cmp/totaleq.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 28 |
5 files changed, 20 insertions, 22 deletions
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<E: Copy>(m: &_mod, _sp: span, _id: node_id, (e, v): (E, vt<E>)) for m.items.iter().advance |i| { (v.visit_item)(*i, (copy e, v)); } } -pub fn visit_view_item<E>(_vi: @view_item, (_e, _v): (E, vt<E>)) { } +pub fn visit_view_item<E>(_vi: &view_item, (_e, _v): (E, vt<E>)) { } -pub fn visit_local<E: Copy>(loc: @local, (e, v): (E, vt<E>)) { +pub fn visit_local<E: Copy>(loc: &local, (e, v): (E, vt<E>)) { (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<E: Copy>(loc: @local, (e, v): (E, vt<E>)) { } } -fn visit_trait_ref<E: Copy>(tref: @ast::trait_ref, (e, v): (E, vt<E>)) { +fn visit_trait_ref<E: Copy>(tref: &ast::trait_ref, (e, v): (E, vt<E>)) { visit_path(tref.path, (e, v)); } -pub fn visit_item<E: Copy>(i: @item, (e, v): (E, vt<E>)) { +pub fn visit_item<E: Copy>(i: &item, (e, v): (E, vt<E>)) { match i.node { item_static(t, _, ex) => { (v.visit_ty)(t, (copy e, v)); @@ -230,9 +230,9 @@ pub fn visit_enum_def<E: Copy>(enum_definition: &ast::enum_def, } } -pub fn skip_ty<E>(_t: @Ty, (_e,_v): (E, vt<E>)) {} +pub fn skip_ty<E>(_t: &Ty, (_e,_v): (E, vt<E>)) {} -pub fn visit_ty<E: Copy>(t: @Ty, (e, v): (E, vt<E>)) { +pub fn visit_ty<E: Copy>(t: &Ty, (e, v): (E, vt<E>)) { 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<E: Copy>(t: @Ty, (e, v): (E, vt<E>)) { } } -pub fn visit_path<E: Copy>(p: @Path, (e, v): (E, vt<E>)) { +pub fn visit_path<E: Copy>(p: &Path, (e, v): (E, vt<E>)) { for p.types.iter().advance |tp| { (v.visit_ty)(*tp, (copy e, v)); } } -pub fn visit_pat<E: Copy>(p: @pat, (e, v): (E, vt<E>)) { +pub fn visit_pat<E: Copy>(p: &pat, (e, v): (E, vt<E>)) { match p.node { pat_enum(path, ref children) => { visit_path(path, (copy e, v)); @@ -322,7 +322,7 @@ pub fn visit_pat<E: Copy>(p: @pat, (e, v): (E, vt<E>)) { } } -pub fn visit_foreign_item<E: Copy>(ni: @foreign_item, (e, v): (E, vt<E>)) { +pub fn visit_foreign_item<E: Copy>(ni: &foreign_item, (e, v): (E, vt<E>)) { 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<E: Copy>( } } -pub fn visit_struct_field<E: Copy>(sf: @struct_field, (e, v): (E, vt<E>)) { +pub fn visit_struct_field<E: Copy>(sf: &struct_field, (e, v): (E, vt<E>)) { (v.visit_ty)(sf.node.ty, (e, v)); } -pub fn visit_struct_method<E: Copy>(m: @method, (e, v): (E, vt<E>)) { +pub fn visit_struct_method<E: Copy>(m: &method, (e, v): (E, vt<E>)) { visit_method_helper(m, (e, v)); } @@ -428,7 +428,7 @@ pub fn visit_block<E: Copy>(b: &blk, (e, v): (E, vt<E>)) { visit_expr_opt(b.node.expr, (e, v)); } -pub fn visit_stmt<E>(s: @stmt, (e, v): (E, vt<E>)) { +pub fn visit_stmt<E>(s: &stmt, (e, v): (E, vt<E>)) { 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<E>(s: @stmt, (e, v): (E, vt<E>)) { } } -pub fn visit_decl<E: Copy>(d: @decl, (e, v): (E, vt<E>)) { +pub fn visit_decl<E: Copy>(d: &decl, (e, v): (E, vt<E>)) { match d.node { decl_local(ref loc) => (v.visit_local)(*loc, (e, v)), decl_item(it) => (v.visit_item)(it, (e, v)) |
