about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-03-20 00:09:47 -0700
committerbors <bors@rust-lang.org>2013-03-20 00:09:47 -0700
commitdb4dc1ffe29045361c34abab8d810d2c717b82e0 (patch)
tree3b82df18e18849d74e4b00b86007282ec30c5cbb /src/libsyntax/parse
parent01e179840fe57c9d2a574613b0cafce756520894 (diff)
parent3fac7cce8fb3fb50328e2c2051532361d7d25aaf (diff)
downloadrust-db4dc1ffe29045361c34abab8d810d2c717b82e0.tar.gz
rust-db4dc1ffe29045361c34abab8d810d2c717b82e0.zip
auto merge of #5443 : alexcrichton/rust/less-bad-copy, r=catamorphism
Removes a lot of instances of `/*bad*/ copy` throughout libsyntax/librustc. On the plus side, this shaves about 2s off of the runtime when compiling `librustc` with optimizations.

Ideally I would have run a profiler to figure out which copies are the most critical to remove, but in reality there was a liberal amount of `git grep`s along with some spot checking and removing the easy ones.
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/comments.rs4
-rw-r--r--src/libsyntax/parse/parser.rs13
2 files changed, 9 insertions, 8 deletions
diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs
index b6ec3aff44d..98208bf9f76 100644
--- a/src/libsyntax/parse/comments.rs
+++ b/src/libsyntax/parse/comments.rs
@@ -220,7 +220,7 @@ fn trim_whitespace_prefix_and_push_line(lines: &mut ~[~str],
         if col < len {
             s1 = str::slice(s, col, len);
         } else { s1 = ~""; }
-    } else { s1 = /*bad*/ copy s; }
+    } else { s1 = s; }
     debug!("pushing line: %s", s1);
     lines.push(s1);
 }
@@ -357,8 +357,8 @@ pub fn gather_comments_and_literals(span_diagnostic:
         let TokenAndSpan {tok: tok, sp: sp} = rdr.peek();
         if token::is_lit(&tok) {
             let s = get_str_from(rdr, bstart);
-            literals.push(lit {lit: /*bad*/ copy s, pos: sp.lo});
             debug!("tok lit: %s", s);
+            literals.push(lit {lit: s, pos: sp.lo});
         } else {
             debug!("tok: %s", token::to_str(rdr.interner, &tok));
         }
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 62e1d20e9b2..086bf86b4b2 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -1444,7 +1444,7 @@ pub impl Parser {
                     let (s, z) = p.parse_sep_and_zerok();
                     tt_seq(
                         mk_sp(sp.lo ,p.span.hi),
-                        /*bad*/ copy seq.node,
+                        seq.node,
                         s,
                         z
                     )
@@ -1861,7 +1861,7 @@ pub impl Parser {
         // Turn on the restriction to stop at | or || so we can parse
         // them as the lambda arguments
         let e = self.parse_expr_res(RESTRICT_NO_BAR_OR_DOUBLEBAR_OP);
-        match /*bad*/ copy e.node {
+        match e.node {
             expr_call(f, args, NoSugar) => {
                 let block = self.parse_lambda_block_expr();
                 let last_arg = self.mk_expr(block.span.lo, block.span.hi,
@@ -2135,7 +2135,7 @@ pub impl Parser {
         let lo = self.span.lo;
         let mut hi = self.span.hi;
         let mut pat;
-        match copy *self.token {
+        match *self.token {
           token::UNDERSCORE => { self.bump(); pat = pat_wild; }
           token::AT => {
             self.bump();
@@ -2243,7 +2243,7 @@ pub impl Parser {
             self.expect(&token::RBRACKET);
             pat = ast::pat_vec(before, slice, after);
           }
-          copy tok => {
+          tok => {
             if !is_ident_or_path(&tok)
                 || self.is_keyword(&~"true")
                 || self.is_keyword(&~"false")
@@ -3347,6 +3347,7 @@ pub impl Parser {
                                             VIEW_ITEMS_AND_ITEMS_ALLOWED,
                                             true);
         let mut items: ~[@item] = starting_items;
+        let attrs_remaining_len = attrs_remaining.len();
 
         // looks like this code depends on the invariant that
         // outer attributes can't occur on view items (or macros
@@ -3355,7 +3356,7 @@ pub impl Parser {
         while *self.token != term {
             let mut attrs = self.parse_outer_attributes();
             if first {
-                attrs = vec::append(/*bad*/ copy attrs_remaining, attrs);
+                attrs = attrs_remaining + attrs;
                 first = false;
             }
             debug!("parse_mod_items: parse_item_or_view_item(attrs=%?)",
@@ -3384,7 +3385,7 @@ pub impl Parser {
             debug!("parse_mod_items: attrs=%?", attrs);
         }
 
-        if first && attrs_remaining.len() > 0u {
+        if first && attrs_remaining_len > 0u {
             // We parsed attributes for the first item but didn't find it
             self.fatal(~"expected item");
         }