Skip to content

Commit 7c1eb83

Browse files
catamorphismgraydon
authored andcommitted
rustpkg: Eliminate a copy
1 parent a0080f4 commit 7c1eb83

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/librustpkg/path_util.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ pub fn first_pkgid_src_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option<P
163163
pub fn built_executable_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option<Path> {
164164
let mut result = workspace.push("build");
165165
// should use a target-specific subdirectory
166-
result = mk_output_path(Main, Build, pkgid, &result);
166+
result = mk_output_path(Main, Build, pkgid, result);
167167
debug!("built_executable_in_workspace: checking whether %s exists",
168168
result.to_str());
169169
if os::path_exists(&result) {
@@ -191,7 +191,7 @@ pub fn built_bench_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option<Path>
191191
fn output_in_workspace(pkgid: &PkgId, workspace: &Path, what: OutputType) -> Option<Path> {
192192
let mut result = workspace.push("build");
193193
// should use a target-specific subdirectory
194-
result = mk_output_path(what, Build, pkgid, &result);
194+
result = mk_output_path(what, Build, pkgid, result);
195195
debug!("output_in_workspace: checking whether %s exists",
196196
result.to_str());
197197
if os::path_exists(&result) {
@@ -357,7 +357,7 @@ fn target_file_in_workspace(pkgid: &PkgId, workspace: &Path,
357357
create the %s dir (pkgid=%s, workspace=%s, what=%?, where=%?",
358358
subdir, pkgid.to_str(), workspace.to_str(), what, where)));
359359
}
360-
mk_output_path(what, where, pkgid, &result)
360+
mk_output_path(what, where, pkgid, result)
361361
}
362362

363363
/// Return the directory for <pkgid>'s build artifacts in <workspace>.
@@ -380,17 +380,14 @@ pub fn build_pkg_id_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
380380
/// Return the output file for a given directory name,
381381
/// given whether we're building a library and whether we're building tests
382382
pub fn mk_output_path(what: OutputType, where: Target,
383-
pkg_id: &PkgId, workspace: &Path) -> Path {
383+
pkg_id: &PkgId, workspace: Path) -> Path {
384384
let short_name_with_version = fmt!("%s-%s", pkg_id.short_name,
385385
pkg_id.version.to_str());
386386
// Not local_path.dir_path()! For package foo/bar/blat/, we want
387387
// the executable blat-0.5 to live under blat/
388388
let dir = match where {
389389
// If we're installing, it just goes under <workspace>...
390-
Install => {
391-
// bad copy, but I just couldn't make the borrow checker happy
392-
(*workspace).clone()
393-
}
390+
Install => workspace,
394391
// and if we're just building, it goes in a package-specific subdir
395392
Build => workspace.push_rel(&*pkg_id.local_path)
396393
};

0 commit comments

Comments
 (0)