Skip to content

Commit 18db9a2

Browse files
committed
rustc: One less copy
1 parent 2a86485 commit 18db9a2

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

src/librustc/back/link.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ pub mod jit {
153153
code: entry,
154154
env: ptr::null()
155155
};
156-
let func: &fn(++argv: ~[~str]) = cast::transmute(closure);
156+
let func: &fn(++argv: ~[@~str]) = cast::transmute(closure);
157157

158-
func(~[/*bad*/copy sess.opts.binary]);
158+
func(~[sess.opts.binary]);
159159
}
160160
}
161161
}

src/librustc/driver/driver.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub fn source_name(input: input) -> ~str {
6262
}
6363
}
6464
65-
pub fn default_configuration(sess: Session, +argv0: ~str, input: input) ->
65+
pub fn default_configuration(sess: Session, argv0: @~str, input: input) ->
6666
ast::crate_cfg {
6767
let libc = match sess.targ_cfg.os {
6868
session::os_win32 => ~"msvcrt.dll",
@@ -101,7 +101,7 @@ pub fn default_configuration(sess: Session, +argv0: ~str, input: input) ->
101101
mk(@~"target_word_size", @wordsz),
102102
mk(@~"target_libc", @libc),
103103
// Build bindings.
104-
mk(@~"build_compiler", @argv0),
104+
mk(@~"build_compiler", argv0),
105105
mk(@~"build_input", @source_name(input))];
106106
}
107107

@@ -114,7 +114,7 @@ pub fn append_configuration(+cfg: ast::crate_cfg, +name: ~str)
114114
}
115115
}
116116

117-
pub fn build_configuration(sess: Session, +argv0: ~str, input: input) ->
117+
pub fn build_configuration(sess: Session, argv0: @~str, input: input) ->
118118
ast::crate_cfg {
119119
// Combine the configuration requested by the session (command line) with
120120
// some default and generated configuration items
@@ -523,7 +523,7 @@ pub fn host_triple() -> ~str {
523523
};
524524
}
525525
526-
pub fn build_session_options(+binary: ~str,
526+
pub fn build_session_options(binary: @~str,
527527
matches: &getopts::Matches,
528528
demitter: diagnostic::Emitter)
529529
-> @session::options {

src/librustc/driver/session.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pub struct options {
131131
// will be added to the crate AST node. This should not be used for
132132
// anything except building the full crate config prior to parsing.
133133
cfg: ast::crate_cfg,
134-
binary: ~str,
134+
binary: @~str,
135135
test: bool,
136136
parse_only: bool,
137137
no_trans: bool,
@@ -303,7 +303,7 @@ pub fn basic_options() -> @options {
303303
maybe_sysroot: None,
304304
target_triple: host_triple(),
305305
cfg: ~[],
306-
binary: ~"rustc",
306+
binary: @~"rustc",
307307
test: false,
308308
parse_only: false,
309309
no_trans: false,

src/librustc/rustc.rc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
206206
::core::logging::console_off();
207207

208208
let mut args = /*bad*/copy *args;
209-
let binary = args.shift();
209+
let binary = @args.shift();
210210

211-
if args.is_empty() { usage(binary); return; }
211+
if args.is_empty() { usage(*binary); return; }
212212

213213
let matches =
214214
&match getopts::groups::getopts(args, optgroups()) {
@@ -219,7 +219,7 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
219219
};
220220

221221
if opt_present(matches, ~"h") || opt_present(matches, ~"help") {
222-
usage(binary);
222+
usage(*binary);
223223
return;
224224
}
225225

@@ -236,7 +236,7 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
236236
}
237237

238238
if opt_present(matches, ~"v") || opt_present(matches, ~"version") {
239-
version(binary);
239+
version(*binary);
240240
return;
241241
}
242242
let input = match vec::len(matches.free) {
@@ -253,8 +253,7 @@ pub fn run_compiler(args: &~[~str], demitter: diagnostic::Emitter) {
253253
_ => early_error(demitter, ~"multiple input filenames provided")
254254
};
255255

256-
// XXX: Bad copy.
257-
let sopts = build_session_options(copy binary, matches, demitter);
256+
let sopts = build_session_options(binary, matches, demitter);
258257
let sess = build_session(sopts, demitter);
259258
let odir = getopts::opt_maybe_str(matches, ~"out-dir");
260259
let odir = odir.map(|o| Path(*o));

0 commit comments

Comments
 (0)