Change .join("") to .concat() (#58200)
Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - N/A
This commit is contained in:
1 parent
2961f5ae23
commit
df4058ebfe
16 files changed
+32
-30
No files matched your search
@@ -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();
|
||||
|
||||
@@ -529,7 +529,7 @@ async fn predict_openai(
|
||||
_ => None,
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join(""),
|
||||
.concat(),
|
||||
}),
|
||||
_ => None,
|
||||
})
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -338,7 +338,7 @@ impl ToString for Hunk {
|
||||
.iter()
|
||||
.map(|line| line.to_string() + "\n")
|
||||
.collect::<Vec<String>>()
|
||||
.join("");
|
||||
.concat();
|
||||
format!("{header}\n{lines}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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()
|
||||
};
|
||||
|
||||
|
||||
@@ -2582,7 +2582,7 @@ impl GitPanel {
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join("");
|
||||
.concat();
|
||||
|
||||
if compressed.len() <= max_bytes {
|
||||
return compressed;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -305,7 +305,7 @@ impl MessageContent {
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join(""),
|
||||
.concat(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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,
|
||||
})),
|
||||
|
||||
@@ -464,7 +464,7 @@ impl PickerDelegate for TasksModalDelegate {
|
||||
.iter()
|
||||
.map(|tag| format!("\n#{}", tag))
|
||||
.collect::<Vec<_>>()
|
||||
.join("")
|
||||
.concat()
|
||||
.as_str(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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, _| {
|
||||
|
||||
@@ -83,7 +83,7 @@ impl ModeIndicator {
|
||||
.map(|count| format!("{}", count)),
|
||||
)
|
||||
.collect::<Vec<_>>()
|
||||
.join("")
|
||||
.concat()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user