Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Change .join("") to .concat() (#58200)

Miguel Raz Guzmán Macedodf4058ebfe26
diff --git a/crates/agent_ui/src/threads_archive_view.rs b/crates/agent_ui/src/threads_archive_view.rs
index f8583ba5b60..a86c902443c 100644
--- a/crates/agent_ui/src/threads_archive_view.rs
+++ b/crates/agent_ui/src/threads_archive_view.rs
@@ -1340,7 +1340,7 @@ impl PickerDelegate for ProjectPickerDelegate {
.ordered_paths()
.map(|path| path.compact().to_string_lossy().into_owned())
.collect::<Vec<_>>()
- .join("");
+ .concat();
StringMatchCandidate::new(id, &combined_string)
})
.collect();
@@ -1376,7 +1376,7 @@ impl PickerDelegate for ProjectPickerDelegate {
.ordered_paths()
.map(|path| path.compact().to_string_lossy().into_owned())
.collect::<Vec<_>>()
- .join("");
+ .concat();
StringMatchCandidate::new(id, &combined_string)
})
.collect();
diff --git a/crates/edit_prediction_cli/src/predict.rs b/crates/edit_prediction_cli/src/predict.rs
index c925527feb6..a78d4d12d70 100644
--- a/crates/edit_prediction_cli/src/predict.rs
+++ b/crates/edit_prediction_cli/src/predict.rs
@@ -529,7 +529,7 @@ async fn predict_openai(
_ => None,
})
.collect::<Vec<_>>()
- .join(""),
+ .concat(),
}),
_ => None,
})
diff --git a/crates/edit_prediction_cli/src/qa.rs b/crates/edit_prediction_cli/src/qa.rs
index a2c5ad30b94..81a2a77b27c 100644
--- a/crates/edit_prediction_cli/src/qa.rs
+++ b/crates/edit_prediction_cli/src/qa.rs
@@ -221,7 +221,7 @@ pub async fn run_qa(
_ => None,
})
.collect::<Vec<_>>()
- .join("")
+ .concat()
}
BatchProvider::Openai => {
let client = if args.no_batch {
@@ -255,13 +255,13 @@ pub async fn run_qa(
_ => None,
})
.collect::<Vec<_>>()
- .join(""),
+ .concat(),
})
}
_ => None,
})
.collect::<Vec<_>>()
- .join("")
+ .concat()
}
};
diff --git a/crates/edit_prediction_cli/src/reorder_patch.rs b/crates/edit_prediction_cli/src/reorder_patch.rs
index 74018cae405..aed393a15b0 100644
--- a/crates/edit_prediction_cli/src/reorder_patch.rs
+++ b/crates/edit_prediction_cli/src/reorder_patch.rs
@@ -338,7 +338,7 @@ impl ToString for Hunk {
.iter()
.map(|line| line.to_string() + "\n")
.collect::<Vec<String>>()
- .join("");
+ .concat();
format!("{header}\n{lines}")
}
}
diff --git a/crates/edit_prediction_cli/src/repair.rs b/crates/edit_prediction_cli/src/repair.rs
index 751e55a8b1c..a6f82bc6453 100644
--- a/crates/edit_prediction_cli/src/repair.rs
+++ b/crates/edit_prediction_cli/src/repair.rs
@@ -367,7 +367,7 @@ pub async fn run_repair(
_ => None,
})
.collect::<Vec<_>>()
- .join("")
+ .concat()
}
BatchProvider::Openai => {
let client = if args.no_batch {
@@ -414,13 +414,13 @@ pub async fn run_repair(
_ => None,
})
.collect::<Vec<_>>()
- .join(""),
+ .concat(),
})
}
_ => None,
})
.collect::<Vec<_>>()
- .join("")
+ .concat()
}
};
diff --git a/crates/editor/src/inlays/inlay_hints.rs b/crates/editor/src/inlays/inlay_hints.rs
index ac3133ea89c..0efc4355a62 100644
--- a/crates/editor/src/inlays/inlay_hints.rs
+++ b/crates/editor/src/inlays/inlay_hints.rs
@@ -2324,8 +2324,8 @@ pub mod tests {
fs.insert_tree(
path!("/a"),
json!({
- "main.rs": format!("fn main() {{\n{}\n}}", (0..501).map(|i| format!("let i = {i};\n")).collect::<Vec<_>>().join("")),
- "other.rs": format!("fn main() {{\n{}\n}}", (0..501).map(|j| format!("let j = {j};\n")).collect::<Vec<_>>().join("")),
+ "main.rs": format!("fn main() {{\n{}\n}}", (0..501).map(|i| format!("let i = {i};\n")).collect::<String>()),
+ "other.rs": format!("fn main() {{\n{}\n}}", (0..501).map(|j| format!("let j = {j};\n")).collect::<String>()),
}),
)
.await;
@@ -2693,7 +2693,7 @@ pub mod tests {
fs.insert_tree(
path!("/a"),
json!({
- "main.rs": format!("fn main() {{\n{}\n}}", (0..200).map(|i| format!("let i = {i};\n")).collect::<Vec<_>>().join("")),
+ "main.rs": format!("fn main() {{\n{}\n}}", (0..200).map(|i| format!("let i = {i};\n")).collect::<String>()),
"lib.rs": r#"let a = 1;
let b = 2;
let c = 3;"#
@@ -2940,8 +2940,8 @@ let c = 3;"#
fs.insert_tree(
path!("/a"),
json!({
- "main.rs": format!("fn main() {{\n{}\n}}", (0..501).map(|i| format!("let i = {i};\n")).collect::<Vec<_>>().join("")),
- "other.rs": format!("fn main() {{\n{}\n}}", (0..501).map(|j| format!("let j = {j};\n")).collect::<Vec<_>>().join("")),
+ "main.rs": format!("fn main() {{\n{}\n}}", (0..501).map(|i| format!("let i = {i};\n")).collect::<String>()),
+ "other.rs": format!("fn main() {{\n{}\n}}", (0..501).map(|j| format!("let j = {j};\n")).collect::<String>()),
}),
)
.await;
diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs
index 9d5ad821ed7..884f5a83251 100644
--- a/crates/editor/src/items.rs
+++ b/crates/editor/src/items.rs
@@ -1786,7 +1786,7 @@ impl SearchableItem for Editor {
let text: Cow<_> = if text.len() == 1 {
text.first().cloned().unwrap().into()
} else {
- let joined_chunks = text.join("");
+ let joined_chunks = text.concat();
joined_chunks.into()
};
@@ -1818,7 +1818,7 @@ impl SearchableItem for Editor {
let text: Cow<_> = if text.len() == 1 {
text.first().cloned().unwrap().into()
} else {
- let joined_chunks = text.join("");
+ let joined_chunks = text.concat();
joined_chunks.into()
};
diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs
index b8d0677fa22..9a239c2a817 100644
--- a/crates/git_ui/src/git_panel.rs
+++ b/crates/git_ui/src/git_panel.rs
@@ -2582,7 +2582,7 @@ impl GitPanel {
}
})
.collect::<Vec<_>>()
- .join("");
+ .concat();
if compressed.len() <= max_bytes {
return compressed;
diff --git a/crates/gpui_macos/src/keyboard.rs b/crates/gpui_macos/src/keyboard.rs
index 63e56a260a2..2b5b644a3ae 100644
--- a/crates/gpui_macos/src/keyboard.rs
+++ b/crates/gpui_macos/src/keyboard.rs
@@ -106,7 +106,7 @@ impl MacKeyboardMapper {
//
// These mappings were generated by running https://github.com/ConradIrwin/keyboard-inspector, tidying up the
// output to remove languages with no mappings and other oddities, and converting it to a less verbose representation with:
-// jq -s 'map(to_entries | map({key: .key, value: [(.value | to_entries | map(.key) | join("")), (.value | to_entries | map(.value) | join(""))]}) | from_entries) | add'
+// jq -s 'map(to_entries | map({key: .key, value: [(.value | to_entries | map(.key) | concat()), (.value | to_entries | map(.value) | concat())]}) | from_entries) | add'
// From there I used multi-cursor to produce this match statement.
fn get_key_equivalents(layout_id: &str) -> Option<HashMap<char, char>> {
let mappings: &[(char, char)] = match layout_id {
diff --git a/crates/open_router/src/open_router.rs b/crates/open_router/src/open_router.rs
index 306f2c22cb4..83f744e101e 100644
--- a/crates/open_router/src/open_router.rs
+++ b/crates/open_router/src/open_router.rs
@@ -305,7 +305,7 @@ impl MessageContent {
}
})
.collect::<Vec<_>>()
- .join(""),
+ .concat(),
}
}
}
diff --git a/crates/recent_projects/src/recent_projects.rs b/crates/recent_projects/src/recent_projects.rs
index 80733c32255..3ad59a14db5 100644
--- a/crates/recent_projects/src/recent_projects.rs
+++ b/crates/recent_projects/src/recent_projects.rs
@@ -981,7 +981,7 @@ impl PickerDelegate for RecentProjectsDelegate {
.ordered_paths()
.map(|path| path.compact().to_string_lossy().into_owned())
.collect::<Vec<_>>()
- .join("");
+ .concat();
StringMatchCandidate::new(id, &combined_string)
})
.collect();
@@ -1006,7 +1006,7 @@ impl PickerDelegate for RecentProjectsDelegate {
.ordered_paths()
.map(|path| path.compact().to_string_lossy().into_owned())
.collect::<Vec<_>>()
- .join("");
+ .concat();
StringMatchCandidate::new(id, &combined_string)
})
.collect();
diff --git a/crates/recent_projects/src/sidebar_recent_projects.rs b/crates/recent_projects/src/sidebar_recent_projects.rs
index c5d1203bf28..5e44e1a90ce 100644
--- a/crates/recent_projects/src/sidebar_recent_projects.rs
+++ b/crates/recent_projects/src/sidebar_recent_projects.rs
@@ -203,7 +203,7 @@ impl PickerDelegate for SidebarRecentProjectsDelegate {
.ordered_paths()
.map(|path| path.compact().to_string_lossy().into_owned())
.collect::<Vec<_>>()
- .join("");
+ .concat();
StringMatchCandidate::new(id, &combined_string)
})
.collect();
diff --git a/crates/repl/src/notebook/cell.rs b/crates/repl/src/notebook/cell.rs
index cf602a46def..2267c135c17 100644
--- a/crates/repl/src/notebook/cell.rs
+++ b/crates/repl/src/notebook/cell.rs
@@ -176,7 +176,7 @@ impl Cell {
source,
..
} => {
- let source = source.join("");
+ let source = source.concat();
let entity = cx.new(|cx| {
MarkdownCell::new(
@@ -198,7 +198,7 @@ impl Cell {
source,
outputs,
} => {
- let text = source.join("");
+ let text = source.concat();
let outputs = convert_outputs(outputs, window, cx);
Cell::Code(cx.new(|cx| {
@@ -223,7 +223,7 @@ impl Cell {
} => Cell::Raw(cx.new(|_| RawCell {
id: id.clone(),
metadata: metadata.clone(),
- source: source.join(""),
+ source: source.concat(),
selected: false,
cell_position: None,
})),
diff --git a/crates/tasks_ui/src/modal.rs b/crates/tasks_ui/src/modal.rs
index f5a416ad3c3..22ad76ca6e7 100644
--- a/crates/tasks_ui/src/modal.rs
+++ b/crates/tasks_ui/src/modal.rs
@@ -464,7 +464,7 @@ impl PickerDelegate for TasksModalDelegate {
.iter()
.map(|tag| format!("\n#{}", tag))
.collect::<Vec<_>>()
- .join("")
+ .concat()
.as_str(),
);
}
diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs
index 63943a20225..61646d72d77 100644
--- a/crates/terminal_view/src/terminal_view.rs
+++ b/crates/terminal_view/src/terminal_view.rs
@@ -14,7 +14,6 @@ use gpui::{
Pixels, Point as GpuiPoint, Render, ScrollWheelEvent, Styled, Subscription, Task, TaskExt,
WeakEntity, actions, anchored, deferred, div,
};
-use itertools::Itertools;
use menu;
use persistence::TerminalDb;
use project::{Project, ProjectEntryId, search::SearchQuery};
@@ -927,7 +926,10 @@ impl TerminalView {
}
pub fn add_paths_to_terminal(&self, paths: &[PathBuf], window: &mut Window, cx: &mut App) {
- let mut text = paths.iter().map(|path| format!(" {path:?}")).join("");
+ let mut text = paths
+ .iter()
+ .map(|path| format!(" {path:?}"))
+ .collect::<String>();
text.push(' ');
window.focus(&self.focus_handle(cx), cx);
self.terminal.update(cx, |terminal, _| {
diff --git a/crates/vim/src/mode_indicator.rs b/crates/vim/src/mode_indicator.rs
index daab005183d..39195a74673 100644
--- a/crates/vim/src/mode_indicator.rs
+++ b/crates/vim/src/mode_indicator.rs
@@ -83,7 +83,7 @@ impl ModeIndicator {
.map(|count| format!("{}", count)),
)
.collect::<Vec<_>>()
- .join("")
+ .concat()
}
}