Skip to content

Commit

Permalink
Do not base path to append extension
Browse files Browse the repository at this point in the history
We already have ownership of the base path, so no need to clone it (within
Path::with_extension).
  • Loading branch information
Mark-Simulacrum authored and sinkuu committed Jan 21, 2020
1 parent 8c6067c commit dc97181
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/librustc_session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,6 @@ impl OutputFilenames {
/// Like temp_path, but also supports things where there is no corresponding
/// OutputType, like noopt-bitcode or lto-bitcode.
pub fn temp_path_ext(&self, ext: &str, codegen_unit_name: Option<&str>) -> PathBuf {
let base = self.out_directory.join(&self.filestem);

let mut extension = String::new();

if let Some(codegen_unit_name) = codegen_unit_name {
Expand All @@ -509,11 +507,13 @@ impl OutputFilenames {
extension.push_str(ext);
}

base.with_extension(extension)
self.with_extension(&extension)
}

pub fn with_extension(&self, extension: &str) -> PathBuf {
self.out_directory.join(&self.filestem).with_extension(extension)
let mut path = self.out_directory.join(&self.filestem);
path.set_extension(extension);
path
}
}

Expand Down

0 comments on commit dc97181

Please sign in to comment.