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
@@ -604,7 +604,7 @@ fn highlights_for_path(
// Again subset the highlight positions to just those that line up with the file_name
// again adjusted to the start of the file_name
let file_name_text_and_positions = path.file_name().map(|file_name| {
let file_name_text = file_name.to_string_lossy().to_string();
let file_name_text = file_name.to_string_lossy().into_owned();
let file_name_start_byte = path_byte_len - file_name_text.len();
let highlight_positions = path_positions
.iter()
@@ -369,7 +369,7 @@ impl RenderOnce for SshConnectionHeader {
)
.child(div().overflow_x_hidden().text_ellipsis().children(
self.paths.into_iter().map(|path| {
Label::new(path.to_string_lossy().to_string())
Label::new(path.to_string_lossy().into_owned())
.size(LabelSize::Small)
.color(Color::Muted)
}),
+1 -1
View File
@@ -238,7 +238,7 @@ impl ProjectPicker {
update_settings_file(fs, cx, {
let paths = paths
.iter()
.map(|path| path.to_string_lossy().to_string())
.map(|path| path.to_string_lossy().into_owned())
.collect();
move |settings, _| match index {
ServerIndex::Ssh(index) => {