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:
@@ -241,7 +241,7 @@ impl Item for FileDiffView {
|
||||
buffer
|
||||
.read(cx)
|
||||
.file()
|
||||
.map(|file| file.full_path(cx).compact().to_string_lossy().to_string())
|
||||
.map(|file| file.full_path(cx).compact().to_string_lossy().into_owned())
|
||||
.unwrap_or_else(|| "untitled".into())
|
||||
};
|
||||
let old_path = path(&self.old_buffer);
|
||||
|
||||
@@ -2085,7 +2085,7 @@ impl GitPanel {
|
||||
.to_string()
|
||||
.into()
|
||||
} else {
|
||||
worktree_abs_path.to_string_lossy().to_string().into()
|
||||
worktree_abs_path.to_string_lossy().into_owned().into()
|
||||
}
|
||||
})
|
||||
.collect_vec();
|
||||
|
||||
@@ -193,7 +193,7 @@ impl TextDiffView {
|
||||
.and_then(|b| {
|
||||
b.read(cx)
|
||||
.file()
|
||||
.map(|f| f.full_path(cx).compact().to_string_lossy().to_string())
|
||||
.map(|f| f.full_path(cx).compact().to_string_lossy().into_owned())
|
||||
})
|
||||
.unwrap_or("untitled".into());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user