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.
This commit is contained in:
Tim Chevalier 2012-04-27 14:21:17 -07:00
parent dc117fecde
commit 2bb3b63ec4
15 changed files with 88 additions and 43 deletions

View file

@ -78,7 +78,7 @@ fn parse_input(sess: session, cfg: ast::crate_cfg, input: str)
if !input_is_stdin(input) {
parse::parse_crate_from_file(input, cfg, sess.parse_sess)
} else {
let src = @str::from_bytes(io::stdin().read_whole_stream());
let src = ~str::from_bytes(io::stdin().read_whole_stream());
parse::parse_crate_from_source_str(input, src, cfg, sess.parse_sess)
}
}