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
+4 -4
View File
@@ -442,7 +442,7 @@ impl HeadlessProject {
let worktree = worktree.read(cx);
proto::AddWorktreeResponse {
worktree_id: worktree.id().to_proto(),
canonicalized_path: canonicalized.to_string_lossy().to_string(),
canonicalized_path: canonicalized.to_string_lossy().into_owned(),
}
})?;
@@ -672,7 +672,7 @@ impl HeadlessProject {
while let Some(path) = response.next().await {
let path = path?;
if let Some(file_name) = path.file_name() {
entries.push(file_name.to_string_lossy().to_string());
entries.push(file_name.to_string_lossy().into_owned());
if check_info {
let is_dir = fs.is_dir(&path).await;
entry_info.push(proto::EntryInfo { is_dir });
@@ -699,7 +699,7 @@ impl HeadlessProject {
Ok(proto::GetPathMetadataResponse {
exists: metadata.is_some(),
is_dir,
path: expanded.to_string_lossy().to_string(),
path: expanded.to_string_lossy().into_owned(),
})
}
@@ -743,7 +743,7 @@ impl HeadlessProject {
let command = process
.cmd()
.iter()
.map(|s| s.to_string_lossy().to_string())
.map(|s| s.to_string_lossy().into_owned())
.collect::<Vec<_>>();
processes.push(proto::ProcessInfo {