diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-04-27 14:21:17 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-04-30 10:44:31 -0700 |
| commit | 2bb3b63ec4379b812aeceb690d78763ec55d3cbb (patch) | |
| tree | f189a83d88971f52d155fb91438a4d8ad81033a4 /src/librustsyntax/parse | |
| parent | dc117fecde14706b3ab5fbcd64f743dba6de9e1b (diff) | |
| download | rust-2bb3b63ec4379b812aeceb690d78763ec55d3cbb.tar.gz rust-2bb3b63ec4379b812aeceb690d78763ec55d3cbb.zip | |
Eliminate a copy in syntax::parse::new_parser_from_file
Fixing a FIXME turned out to be pretty involved. I added an io function that returns a unique boxed string (for the contents of a file) rather than a string, and went from there. Also made the src field of codemap a unique boxed string. This doesn't seem to make that much difference in amount of allocation according to valgrind (disappointingly), but I also had to introduce a copy somewhere else pending a new snapshot, so maybe that's it.
Diffstat (limited to 'src/librustsyntax/parse')
| -rw-r--r-- | src/librustsyntax/parse/comments.rs | 2 | ||||
| -rw-r--r-- | src/librustsyntax/parse/lexer.rs | 2 | ||||
| -rw-r--r-- | src/librustsyntax/parse/token.rs | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/src/librustsyntax/parse/comments.rs b/src/librustsyntax/parse/comments.rs index 493ed7b369b..15319e21f40 100644 --- a/src/librustsyntax/parse/comments.rs +++ b/src/librustsyntax/parse/comments.rs @@ -154,7 +154,7 @@ fn gather_comments_and_literals(span_diagnostic: diagnostic::span_handler, path: str, srdr: io::reader) -> {cmnts: [cmnt], lits: [lit]} { - let src = @str::from_bytes(srdr.read_whole_stream()); + let src = ~str::from_bytes(srdr.read_whole_stream()); let itr = @interner::mk::<str>(str::hash, str::eq); let rdr = new_reader(span_diagnostic, codemap::new_filemap(path, src, 0u, 0u), itr); diff --git a/src/librustsyntax/parse/lexer.rs b/src/librustsyntax/parse/lexer.rs index ec9f785db2f..321bf076a1e 100644 --- a/src/librustsyntax/parse/lexer.rs +++ b/src/librustsyntax/parse/lexer.rs @@ -6,7 +6,7 @@ export reader, new_reader, next_token, is_whitespace; type reader = @{ span_diagnostic: diagnostic::span_handler, - src: @str, + src: ~str, mut col: uint, mut pos: uint, mut curr: char, diff --git a/src/librustsyntax/parse/token.rs b/src/librustsyntax/parse/token.rs index 3f9ce9d91b6..c962d4ec16c 100644 --- a/src/librustsyntax/parse/token.rs +++ b/src/librustsyntax/parse/token.rs @@ -124,7 +124,7 @@ fn to_str(in: interner<str>, t: token) -> str { /* Literals */ LIT_INT(c, ast::ty_char) { - // FIXME: escape. + // FIXME: escape. (#2306) let mut tmp = "'"; str::push_char(tmp, c as char); str::push_char(tmp, '\''); @@ -140,7 +140,7 @@ fn to_str(in: interner<str>, t: token) -> str { ret interner::get::<str>(in, s) + ast_util::float_ty_to_str(t); } - LIT_STR(s) { // FIXME: escape. + LIT_STR(s) { // FIXME: escape. (#2306) ret "\"" + interner::get::<str>(in, s) + "\""; } |
