Skip to content

Commit

Permalink
compiletest: Remove superfluous to_string calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Sawyer47 committed Jun 25, 2014
1 parent 91be86a commit b53acd5
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 95 deletions.
45 changes: 16 additions & 29 deletions src/compiletest/compiletest.rs
Expand Up @@ -48,9 +48,7 @@ fn start(argc: int, argv: **u8) -> int {

pub fn main() {
let args = os::args();
let config = parse_config(args.move_iter()
.map(|x| x.to_string())
.collect());
let config = parse_config(args);
log_config(&config);
run_tests(&config);
}
Expand Down Expand Up @@ -131,17 +129,15 @@ pub fn parse_config(args: Vec<String> ) -> Config {
};

Config {
compile_lib_path: matches.opt_str("compile-lib-path")
.unwrap()
.to_string(),
run_lib_path: matches.opt_str("run-lib-path").unwrap().to_string(),
compile_lib_path: matches.opt_str("compile-lib-path").unwrap(),
run_lib_path: matches.opt_str("run-lib-path").unwrap(),
rustc_path: opt_path(matches, "rustc-path"),
clang_path: matches.opt_str("clang-path").map(|s| Path::new(s)),
llvm_bin_path: matches.opt_str("llvm-bin-path").map(|s| Path::new(s)),
src_base: opt_path(matches, "src-base"),
build_base: opt_path(matches, "build-base"),
aux_base: opt_path(matches, "aux-base"),
stage_id: matches.opt_str("stage-id").unwrap().to_string(),
stage_id: matches.opt_str("stage-id").unwrap(),
mode: FromStr::from_str(matches.opt_str("mode")
.unwrap()
.as_slice()).expect("invalid mode"),
Expand All @@ -155,32 +151,23 @@ pub fn parse_config(args: Vec<String> ) -> Config {
ratchet_noise_percent:
matches.opt_str("ratchet-noise-percent")
.and_then(|s| from_str::<f64>(s.as_slice())),
runtool: matches.opt_str("runtool").map(|x| x.to_string()),
host_rustcflags: matches.opt_str("host-rustcflags")
.map(|x| x.to_string()),
target_rustcflags: matches.opt_str("target-rustcflags")
.map(|x| x.to_string()),
runtool: matches.opt_str("runtool"),
host_rustcflags: matches.opt_str("host-rustcflags"),
target_rustcflags: matches.opt_str("target-rustcflags"),
jit: matches.opt_present("jit"),
target: opt_str2(matches.opt_str("target").map(|x| x.to_string())),
host: opt_str2(matches.opt_str("host").map(|x| x.to_string())),
target: opt_str2(matches.opt_str("target")),
host: opt_str2(matches.opt_str("host")),
android_cross_path: opt_path(matches, "android-cross-path"),
adb_path: opt_str2(matches.opt_str("adb-path")
.map(|x| x.to_string())),
adb_test_dir: opt_str2(matches.opt_str("adb-test-dir")
.map(|x| x.to_string())),
adb_path: opt_str2(matches.opt_str("adb-path")),
adb_test_dir: opt_str2(matches.opt_str("adb-test-dir")),
adb_device_status:
"arm-linux-androideabi" ==
opt_str2(matches.opt_str("target")
.map(|x| x.to_string())).as_slice() &&
opt_str2(matches.opt_str("target")).as_slice() &&
"(none)" !=
opt_str2(matches.opt_str("adb-test-dir")
.map(|x| x.to_string())).as_slice() &&
!opt_str2(matches.opt_str("adb-test-dir")
.map(|x| x.to_string())).is_empty(),
lldb_python_dir: matches.opt_str("lldb-python-dir")
.map(|x| x.to_string()),
test_shard: test::opt_shard(matches.opt_str("test-shard")
.map(|x| x.to_string())),
opt_str2(matches.opt_str("adb-test-dir")).as_slice() &&
!opt_str2(matches.opt_str("adb-test-dir")).is_empty(),
lldb_python_dir: matches.opt_str("lldb-python-dir"),
test_shard: test::opt_shard(matches.opt_str("test-shard")),
verbose: matches.opt_present("verbose")
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/compiletest/header.rs
Expand Up @@ -170,23 +170,23 @@ fn iter_header(testfile: &Path, it: |&str| -> bool) -> bool {
}

fn parse_error_pattern(line: &str) -> Option<String> {
parse_name_value_directive(line, "error-pattern".to_string())
parse_name_value_directive(line, "error-pattern")
}

fn parse_aux_build(line: &str) -> Option<String> {
parse_name_value_directive(line, "aux-build".to_string())
parse_name_value_directive(line, "aux-build")
}

fn parse_compile_flags(line: &str) -> Option<String> {
parse_name_value_directive(line, "compile-flags".to_string())
parse_name_value_directive(line, "compile-flags")
}

fn parse_run_flags(line: &str) -> Option<String> {
parse_name_value_directive(line, "run-flags".to_string())
parse_name_value_directive(line, "run-flags")
}

fn parse_check_line(line: &str) -> Option<String> {
parse_name_value_directive(line, "check".to_string())
parse_name_value_directive(line, "check")
}

fn parse_force_host(line: &str) -> bool {
Expand All @@ -206,7 +206,7 @@ fn parse_no_pretty_expanded(line: &str) -> bool {
}

fn parse_exec_env(line: &str) -> Option<(String, String)> {
parse_name_value_directive(line, "exec-env".to_string()).map(|nv| {
parse_name_value_directive(line, "exec-env").map(|nv| {
// nv is either FOO or FOO=BAR
let mut strs: Vec<String> = nv.as_slice()
.splitn('=', 1)
Expand All @@ -225,7 +225,7 @@ fn parse_exec_env(line: &str) -> Option<(String, String)> {
}

fn parse_pp_exact(line: &str, testfile: &Path) -> Option<Path> {
match parse_name_value_directive(line, "pp-exact".to_string()) {
match parse_name_value_directive(line, "pp-exact") {
Some(s) => Some(Path::new(s)),
None => {
if parse_name_directive(line, "pp-exact") {
Expand All @@ -241,7 +241,7 @@ fn parse_name_directive(line: &str, directive: &str) -> bool {
line.contains(directive)
}

pub fn parse_name_value_directive(line: &str, directive: String)
pub fn parse_name_value_directive(line: &str, directive: &str)
-> Option<String> {
let keycolon = format!("{}:", directive);
match line.find_str(keycolon.as_slice()) {
Expand Down

5 comments on commit b53acd5

@bors
Copy link
Contributor

@bors bors commented on b53acd5 Jun 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at Sawyer47@b53acd5

@bors
Copy link
Contributor

@bors bors commented on b53acd5 Jun 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging Sawyer47/rust/de-to-string = b53acd5 into auto

@bors
Copy link
Contributor

@bors bors commented on b53acd5 Jun 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sawyer47/rust/de-to-string = b53acd5 merged ok, testing candidate = 7da94c1

@bors
Copy link
Contributor

@bors bors commented on b53acd5 Jun 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 7da94c1

Please sign in to comment.