Reduce allocations (#30693)
Removes a unnecessary string conversion and some clones Release Notes: - N/A
This commit is contained in:
parent
fcfe4e2c14
commit
bc99a86bb7
17 changed files with 48 additions and 57 deletions
|
@ -269,13 +269,12 @@ impl TerminalError {
|
|||
Err(s) => s,
|
||||
}
|
||||
})
|
||||
.unwrap_or_else(|| {
|
||||
let default_dir =
|
||||
dirs::home_dir().map(|buf| buf.into_os_string().to_string_lossy().to_string());
|
||||
match default_dir {
|
||||
Some(dir) => format!("<none specified, using home directory> {}", dir),
|
||||
None => "<none specified, could not find home directory>".to_string(),
|
||||
}
|
||||
.unwrap_or_else(|| match dirs::home_dir() {
|
||||
Some(dir) => format!(
|
||||
"<none specified, using home directory> {}",
|
||||
dir.into_os_string().to_string_lossy()
|
||||
),
|
||||
None => "<none specified, could not find home directory>".to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue