提交 18db9a29 编写于 作者: T Tim Chevalier

rustc: One less copy

上级 2a864852
......@@ -153,9 +153,9 @@ pub fn exec(sess: Session,
code: entry,
env: ptr::null()
};
let func: &fn(++argv: ~[~str]) = cast::transmute(closure);
let func: &fn(++argv: ~[@~str]) = cast::transmute(closure);
func(~[/*bad*/copy sess.opts.binary]);
func(~[sess.opts.binary]);
}
}
}
......
......@@ -62,7 +62,7 @@ pub fn source_name(input: input) -> ~str {
}
}
pub fn default_configuration(sess: Session, +argv0: ~str, input: input) ->
pub fn default_configuration(sess: Session, argv0: @~str, input: input) ->
ast::crate_cfg {
let libc = match sess.targ_cfg.os {
session::os_win32 => ~"msvcrt.dll",
......@@ -101,7 +101,7 @@ pub fn default_configuration(sess: Session, +argv0: ~str, input: input) ->
mk(@~"target_word_size", @wordsz),
mk(@~"target_libc", @libc),
// Build bindings.
mk(@~"build_compiler", @argv0),
mk(@~"build_compiler", argv0),
mk(@~"build_input", @source_name(input))];
}
......@@ -114,7 +114,7 @@ pub fn append_configuration(+cfg: ast::crate_cfg, +name: ~str)
}
}
pub fn build_configuration(sess: Session, +argv0: ~str, input: input) ->
pub fn build_configuration(sess: Session, argv0: @~str, input: input) ->
ast::crate_cfg {
// Combine the configuration requested by the session (command line) with
// some default and generated configuration items
......@@ -523,7 +523,7 @@ pub fn host_triple() -> ~str {
};
}
pub fn build_session_options(+binary: ~str,
pub fn build_session_options(binary: @~str,
matches: &getopts::Matches,
demitter: diagnostic::Emitter)
-> @session::options {
......
......@@ -131,7 +131,7 @@ pub struct options {
// will be added to the crate AST node. This should not be used for
// anything except building the full crate config prior to parsing.
cfg: ast::crate_cfg,
binary: ~str,
binary: @~str,
test: bool,
parse_only: bool,
no_trans: bool,
......@@ -303,7 +303,7 @@ pub fn basic_options() -> @options {
maybe_sysroot: None,
target_triple: host_triple(),
cfg: ~[],
binary: ~"rustc",
binary: @~"rustc",
test: false,
parse_only: false,
no_trans: false,
......
......@@ -206,9 +206,9 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
::core::logging::console_off();
let mut args = /*bad*/copy *args;
let binary = args.shift();
let binary = @args.shift();
if args.is_empty() { usage(binary); return; }
if args.is_empty() { usage(*binary); return; }
let matches =
&match getopts::groups::getopts(args, optgroups()) {
......@@ -219,7 +219,7 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
};
if opt_present(matches, ~"h") || opt_present(matches, ~"help") {
usage(binary);
usage(*binary);
return;
}
......@@ -236,7 +236,7 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
}
if opt_present(matches, ~"v") || opt_present(matches, ~"version") {
version(binary);
version(*binary);
return;
}
let input = match vec::len(matches.free) {
......@@ -253,8 +253,7 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
_ => early_error(demitter, ~"multiple input filenames provided")
};
// XXX: Bad copy.
let sopts = build_session_options(copy binary, matches, demitter);
let sopts = build_session_options(binary, matches, demitter);
let sess = build_session(sopts, demitter);
let odir = getopts::opt_maybe_str(matches, ~"out-dir");
let odir = odir.map(|o| Path(*o));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册