about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-06-12 18:10:49 -0700
committerbors <bors@rust-lang.org>2013-06-12 18:10:49 -0700
commitda510bfb4a3f6ca805e849372f9bbe7b2b0f6a61 (patch)
treecb272a50c99d8001304f044fd8a1128d30654b61 /src/libsyntax/parse/parser.rs
parent84bed9769b5d15871481b657860ad6a7d0a62f42 (diff)
parent5ebffd46d5f7476c8124856c37538088da0c918e (diff)
downloadrust-da510bfb4a3f6ca805e849372f9bbe7b2b0f6a61.tar.gz
rust-da510bfb4a3f6ca805e849372f9bbe7b2b0f6a61.zip
auto merge of #7086 : huonw/rust/5048, r=graydon
Fixes #5048.

I'm sure this reduces memory usage, but I can't get cgroups to work properly to actually measure memory. (It doesn't appear to offer much speed improvement, but I'm fairly sure it's not slower.)

This is quite huge, so it'd be nice to get a resolution soon.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
-rw-r--r--src/libsyntax/parse/parser.rs37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 8dd80be4f9c..47c0827eb23 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -96,7 +96,6 @@ use core::iterator::IteratorUtil;
 use core::either::Either;
 use core::either;
 use core::hashmap::HashSet;
-use core::str;
 use core::vec;
 
 #[deriving(Eq)]
@@ -263,7 +262,7 @@ pub struct Parser {
     /// extra detail when the same error is seen twice
     obsolete_set: @mut HashSet<ObsoleteSyntax>,
     /// Used to determine the path to externally loaded source files
-    mod_path_stack: @mut ~[~str],
+    mod_path_stack: @mut ~[@str],
 
 }
 
@@ -333,7 +332,7 @@ impl Parser {
     }
     pub fn get_id(&self) -> node_id { next_node_id(self.sess) }
 
-    pub fn id_to_str(&self, id: ident) -> @~str {
+    pub fn id_to_str(&self, id: ident) -> @str {
         get_ident_interner().get(id.name)
     }
 
@@ -2886,7 +2885,7 @@ impl Parser {
         loop {
             match *self.token {
                 token::LIFETIME(lifetime) => {
-                    if str::eq_slice(*self.id_to_str(lifetime), "static") {
+                    if "static" == self.id_to_str(lifetime) {
                         result.push(RegionTyParamBound);
                     } else {
                         self.span_err(*self.span,
@@ -2898,11 +2897,11 @@ impl Parser {
                     let obsolete_bound = match *self.token {
                         token::MOD_SEP => false,
                         token::IDENT(sid, _) => {
-                            match *self.id_to_str(sid) {
-                                ~"send" |
-                                ~"copy" |
-                                ~"const" |
-                                ~"owned" => {
+                            match self.id_to_str(sid).as_slice() {
+                                "send" |
+                                "copy" |
+                                "const" |
+                                "owned" => {
                                     self.obsolete(
                                         *self.span,
                                         ObsoleteLowerCaseKindBounds);
@@ -3364,7 +3363,7 @@ impl Parser {
             }
             if fields.len() == 0 {
                 self.fatal(fmt!("Unit-like struct should be written as `struct %s;`",
-                                *get_ident_interner().get(class_name.name)));
+                                get_ident_interner().get(class_name.name)));
             }
             self.bump();
         } else if *self.token == token::LPAREN {
@@ -3580,8 +3579,8 @@ impl Parser {
         let file_path = match ::attr::first_attr_value_str_by_name(
             attrs, "path") {
 
-            Some(d) => copy *d,
-            None => copy *default_path
+            Some(d) => d,
+            None => default_path
         };
         self.mod_path_stack.push(file_path)
     }
@@ -3599,13 +3598,13 @@ impl Parser {
         let prefix = prefix.dir_path();
         let mod_path_stack = &*self.mod_path_stack;
         let mod_path = Path(".").push_many(*mod_path_stack);
-        let default_path = *token::interner_get(id.name) + ".rs";
+        let default_path = token::interner_get(id.name).to_owned() + ".rs";
         let file_path = match ::attr::first_attr_value_str_by_name(
             outer_attrs, "path") {
             Some(d) => {
-                let path = Path(copy *d);
+                let path = Path(d);
                 if !path.is_absolute {
-                    mod_path.push(copy *d)
+                    mod_path.push(d)
                 } else {
                     path
                 }
@@ -3637,9 +3636,9 @@ impl Parser {
         let m0 = p0.parse_mod_items(token::EOF, first_item_outer_attrs);
         return (ast::item_mod(m0), mod_attrs);
 
-        fn cdir_path_opt(default: ~str, attrs: ~[ast::attribute]) -> ~str {
+        fn cdir_path_opt(default: @str, attrs: ~[ast::attribute]) -> @str {
             match ::attr::first_attr_value_str_by_name(attrs, "path") {
-                Some(d) => copy *d,
+                Some(d) => d,
                 None => default
             }
         }
@@ -4263,7 +4262,7 @@ impl Parser {
 
         let first_ident = self.parse_ident();
         let mut path = ~[first_ident];
-        debug!("parsed view_path: %s", *self.id_to_str(first_ident));
+        debug!("parsed view_path: %s", self.id_to_str(first_ident));
         match *self.token {
           token::EQ => {
             // x = foo::bar
@@ -4528,7 +4527,7 @@ impl Parser {
                                config: copy self.cfg })
     }
 
-    pub fn parse_str(&self) -> @~str {
+    pub fn parse_str(&self) -> @str {
         match *self.token {
             token::LIT_STR(s) => {
                 self.bump();