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:
@@ -622,7 +622,7 @@ impl Worktree {
|
||||
id: self.id().to_proto(),
|
||||
root_name: self.root_name().to_proto(),
|
||||
visible: self.is_visible(),
|
||||
abs_path: self.abs_path().to_string_lossy().to_string(),
|
||||
abs_path: self.abs_path().to_string_lossy().into_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -982,7 +982,7 @@ impl Worktree {
|
||||
.join("~", &*stripped.to_string_lossy())
|
||||
.unwrap()
|
||||
} else {
|
||||
full_path.to_string_lossy().to_string()
|
||||
full_path.to_string_lossy().into_owned()
|
||||
};
|
||||
|
||||
if worktree_relative_path.components().next().is_some() {
|
||||
@@ -2072,7 +2072,7 @@ impl Snapshot {
|
||||
proto::UpdateWorktree {
|
||||
project_id,
|
||||
worktree_id,
|
||||
abs_path: self.abs_path().to_string_lossy().to_string(),
|
||||
abs_path: self.abs_path().to_string_lossy().into_owned(),
|
||||
root_name: self.root_name().to_proto(),
|
||||
updated_entries,
|
||||
removed_entries: Vec::new(),
|
||||
@@ -2415,7 +2415,7 @@ impl LocalSnapshot {
|
||||
proto::UpdateWorktree {
|
||||
project_id,
|
||||
worktree_id,
|
||||
abs_path: self.abs_path().to_string_lossy().to_string(),
|
||||
abs_path: self.abs_path().to_string_lossy().into_owned(),
|
||||
root_name: self.root_name().to_proto(),
|
||||
updated_entries,
|
||||
removed_entries,
|
||||
@@ -5354,7 +5354,7 @@ impl<'a> From<&'a Entry> for proto::Entry {
|
||||
canonical_path: entry
|
||||
.canonical_path
|
||||
.as_ref()
|
||||
.map(|path| path.to_string_lossy().to_string()),
|
||||
.map(|path| path.to_string_lossy().into_owned()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user