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.

Avoid redundant string allocations (#63377)

Miguel Raz Guzmán Macedoa3f6b96ced39
diff --git a/crates/editor/src/input.rs b/crates/editor/src/input.rs
index 1b6fb4ed551..b5f8d6d6135 100644
--- a/crates/editor/src/input.rs
+++ b/crates/editor/src/input.rs
@@ -335,10 +335,7 @@ impl Editor {
);
// Remove shortcode from buffer
- edits.push((
- emoji_shortcode_start..selection.start,
- "".to_string().into(),
- ));
+ edits.push((emoji_shortcode_start..selection.start, Arc::from("")));
new_selections.push((
Selection {
id: selection.id,
diff --git a/crates/git_ui_core/src/worktree_picker.rs b/crates/git_ui_core/src/worktree_picker.rs
index be3a5d195e3..5a4b278bbce 100644
--- a/crates/git_ui_core/src/worktree_picker.rs
+++ b/crates/git_ui_core/src/worktree_picker.rs
@@ -1092,7 +1092,7 @@ impl PickerDelegate for WorktreePickerDelegate {
let label = format!("Create new worktree based on {branch_label}");
let item = create_new_list_item(
- "create-from-current".to_string().into(),
+ SharedString::new_static("create-from-current"),
label.into(),
self.creation_blocked_reason(cx),
selected,
@@ -1109,7 +1109,7 @@ impl PickerDelegate for WorktreePickerDelegate {
let label = format!("Create new worktree based on {branch_label}");
let item = create_new_list_item(
- "create-from-main".to_string().into(),
+ SharedString::new_static("create-from-main"),
label.into(),
self.creation_blocked_reason(cx),
selected,
diff --git a/crates/toolchain_selector/src/toolchain_selector.rs b/crates/toolchain_selector/src/toolchain_selector.rs
index 8402701ec8d..aca4c1ce2d9 100644
--- a/crates/toolchain_selector/src/toolchain_selector.rs
+++ b/crates/toolchain_selector/src/toolchain_selector.rs
@@ -864,7 +864,7 @@ impl ToolchainSelectorDelegate {
Some(())
}
});
- let placeholder_text = "Select a toolchain…".to_string().into();
+ let placeholder_text = Arc::from("Select a toolchain…");
Self {
toolchain_selector,
candidates: Default::default(),