summary refs log tree commit diff
path: root/src/libsyntax/parse/comments.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-06-08 13:37:10 -0700
committerbors <bors@rust-lang.org>2013-06-08 13:37:10 -0700
commit878a9b92ebe1d55c119d9c6ae4636c31ca6d6cd6 (patch)
tree6106d3a76c472a65eae65bda392ac08955fa29f1 /src/libsyntax/parse/comments.rs
parent4aa77198cba0cc49fac2d47f1832b6b33ac57ada (diff)
parent2096d79626029bfbfd7d42668be4705390a2c4ec (diff)
downloadrust-878a9b92ebe1d55c119d9c6ae4636c31ca6d6cd6.tar.gz
rust-878a9b92ebe1d55c119d9c6ae4636c31ca6d6cd6.zip
auto merge of #7004 : dotdash/rust/allocs, r=thestinger
This removes some unnecessary allocations in the lexer, the typechecker and the metadata decoder. Reduces the time spent in the parsing and typechecking passes by about 10% for me.
Diffstat (limited to 'src/libsyntax/parse/comments.rs')
-rw-r--r--src/libsyntax/parse/comments.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs
index 360ea12ec02..57df0fe6f86 100644
--- a/src/libsyntax/parse/comments.rs
+++ b/src/libsyntax/parse/comments.rs
@@ -13,7 +13,7 @@ use core::prelude::*;
 use ast;
 use codemap::{BytePos, CharPos, CodeMap, Pos};
 use diagnostic;
-use parse::lexer::{is_whitespace, get_str_from, reader};
+use parse::lexer::{is_whitespace, with_str_from, reader};
 use parse::lexer::{StringReader, bump, is_eof, nextch, TokenAndSpan};
 use parse::lexer::{is_line_non_doc_comment, is_block_non_doc_comment};
 use parse::lexer;
@@ -352,9 +352,10 @@ pub fn gather_comments_and_literals(span_diagnostic:
         //discard, and look ahead; we're working with internal state
         let TokenAndSpan {tok: tok, sp: sp} = rdr.peek();
         if token::is_lit(&tok) {
-            let s = get_str_from(rdr, bstart);
-            debug!("tok lit: %s", s);
-            literals.push(lit {lit: s, pos: sp.lo});
+            do with_str_from(rdr, bstart) |s| {
+                debug!("tok lit: %s", s);
+                literals.push(lit {lit: s.to_owned(), pos: sp.lo});
+            }
         } else {
             debug!("tok: %s", token::to_str(get_ident_interner(), &tok));
         }