Use into_owned over to_string for Cow<str> (#39024)

This removes unnecessary allocations when the `Cow` is already owned


Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Lukas Wirth
2025-09-27 14:50:10 +00:00
committed by GitHub
parent a063a70cfb
commit 72948e14ee
84 changed files with 169 additions and 161 deletions
+1 -1
View File
@@ -373,7 +373,7 @@ fn get_processes_for_project(project: &Entity<Project>, cx: &mut App) -> Task<Ar
command: process
.cmd()
.iter()
.map(|s| s.to_string_lossy().to_string())
.map(|s| s.to_string_lossy().into_owned())
.collect::<Vec<_>>(),
}
})
+1 -1
View File
@@ -1578,7 +1578,7 @@ impl PickerDelegate for DebugDelegate {
pub(crate) fn resolve_path(path: &mut String) {
if path.starts_with('~') {
let home = paths::home_dir().to_string_lossy().to_string();
let home = paths::home_dir().to_string_lossy().into_owned();
let trimmed_path = path.trim().to_owned();
*path = trimmed_path.replacen('~', &home, 1);
} else if let Some(strip_path) = path.strip_prefix(&format!(".{}", std::path::MAIN_SEPARATOR)) {
@@ -351,7 +351,7 @@ async fn test_handle_successful_run_in_terminal_reverse_request(
.fake_reverse_request::<RunInTerminal>(RunInTerminalRequestArguments {
kind: None,
title: None,
cwd: std::env::temp_dir().to_string_lossy().to_string(),
cwd: std::env::temp_dir().to_string_lossy().into_owned(),
args: vec![],
env: None,
args_can_be_interpreted_by_shell: None,