Fix clippy::redundant_clone
lint violations (#36558)
This removes around 900 unnecessary clones, ranging from cloning a few ints all the way to large data structures and images. A lot of these were fixed using `cargo clippy --fix --workspace --all-targets`, however it often breaks other lints and needs to be run again. This was then followed up with some manual fixing. I understand this is a large diff, but all the changes are pretty trivial. Rust is doing some heavy lifting here for us. Once I get it up to speed with main, I'd appreciate this getting merged rather sooner than later. Release Notes: - N/A
This commit is contained in:
parent
cf7c64d77f
commit
7bdc99abc1
306 changed files with 805 additions and 1102 deletions
|
@ -172,7 +172,7 @@ impl BlameRenderer for GitBlameRenderer {
|
|||
.clone()
|
||||
.unwrap_or("<no name>".to_string())
|
||||
.into(),
|
||||
author_email: blame.author_mail.clone().unwrap_or("".to_string()).into(),
|
||||
author_email: blame.author_mail.unwrap_or("".to_string()).into(),
|
||||
message: details,
|
||||
};
|
||||
|
||||
|
@ -186,7 +186,7 @@ impl BlameRenderer for GitBlameRenderer {
|
|||
.get(0..8)
|
||||
.map(|sha| sha.to_string().into())
|
||||
.unwrap_or_else(|| commit_details.sha.clone());
|
||||
let full_sha = commit_details.sha.to_string().clone();
|
||||
let full_sha = commit_details.sha.to_string();
|
||||
let absolute_timestamp = format_local_timestamp(
|
||||
commit_details.commit_time,
|
||||
OffsetDateTime::now_utc(),
|
||||
|
@ -377,7 +377,7 @@ impl BlameRenderer for GitBlameRenderer {
|
|||
has_parent: true,
|
||||
},
|
||||
repository.downgrade(),
|
||||
workspace.clone(),
|
||||
workspace,
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
|
|
|
@ -48,7 +48,7 @@ pub fn open(
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Workspace>,
|
||||
) {
|
||||
let repository = workspace.project().read(cx).active_repository(cx).clone();
|
||||
let repository = workspace.project().read(cx).active_repository(cx);
|
||||
let style = BranchListStyle::Modal;
|
||||
workspace.toggle_modal(window, cx, |window, cx| {
|
||||
BranchList::new(repository, style, rems(34.), window, cx)
|
||||
|
@ -144,7 +144,7 @@ impl BranchList {
|
|||
})
|
||||
.detach_and_log_err(cx);
|
||||
|
||||
let delegate = BranchListDelegate::new(repository.clone(), style);
|
||||
let delegate = BranchListDelegate::new(repository, style);
|
||||
let picker = cx.new(|cx| Picker::uniform_list(delegate, window, cx));
|
||||
|
||||
let _subscription = cx.subscribe(&picker, |_, _, _, cx| {
|
||||
|
|
|
@ -35,7 +35,7 @@ impl ModalContainerProperties {
|
|||
|
||||
// Calculate width based on character width
|
||||
let mut modal_width = 460.0;
|
||||
let style = window.text_style().clone();
|
||||
let style = window.text_style();
|
||||
let font_id = window.text_system().resolve_font(&style.font());
|
||||
let font_size = style.font_size.to_pixels(window.rem_size());
|
||||
|
||||
|
@ -179,7 +179,7 @@ impl CommitModal {
|
|||
|
||||
let commit_editor = git_panel.update(cx, |git_panel, cx| {
|
||||
git_panel.set_modal_open(true, cx);
|
||||
let buffer = git_panel.commit_message_buffer(cx).clone();
|
||||
let buffer = git_panel.commit_message_buffer(cx);
|
||||
let panel_editor = git_panel.commit_editor.clone();
|
||||
let project = git_panel.project.clone();
|
||||
|
||||
|
@ -285,7 +285,7 @@ impl CommitModal {
|
|||
Some(ContextMenu::build(window, cx, |context_menu, _, _| {
|
||||
context_menu
|
||||
.when_some(keybinding_target.clone(), |el, keybinding_target| {
|
||||
el.context(keybinding_target.clone())
|
||||
el.context(keybinding_target)
|
||||
})
|
||||
.when(has_previous_commit, |this| {
|
||||
this.toggleable_entry(
|
||||
|
@ -482,7 +482,7 @@ impl CommitModal {
|
|||
}),
|
||||
self.render_git_commit_menu(
|
||||
ElementId::Name(format!("split-button-right-{}", commit_label).into()),
|
||||
Some(focus_handle.clone()),
|
||||
Some(focus_handle),
|
||||
)
|
||||
.into_any_element(),
|
||||
)),
|
||||
|
|
|
@ -181,7 +181,7 @@ impl Render for CommitTooltip {
|
|||
.get(0..8)
|
||||
.map(|sha| sha.to_string().into())
|
||||
.unwrap_or_else(|| self.commit.sha.clone());
|
||||
let full_sha = self.commit.sha.to_string().clone();
|
||||
let full_sha = self.commit.sha.to_string();
|
||||
let absolute_timestamp = format_local_timestamp(
|
||||
self.commit.commit_time,
|
||||
OffsetDateTime::now_utc(),
|
||||
|
|
|
@ -55,7 +55,7 @@ pub fn register_editor(editor: &mut Editor, buffer: Entity<MultiBuffer>, cx: &mu
|
|||
buffers: Default::default(),
|
||||
});
|
||||
|
||||
let buffers = buffer.read(cx).all_buffers().clone();
|
||||
let buffers = buffer.read(cx).all_buffers();
|
||||
for buffer in buffers {
|
||||
buffer_added(editor, buffer, cx);
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ fn buffer_added(editor: &mut Editor, buffer: Entity<Buffer>, cx: &mut Context<Ed
|
|||
let subscription = cx.subscribe(&conflict_set, conflicts_updated);
|
||||
BufferConflicts {
|
||||
block_ids: Vec::new(),
|
||||
conflict_set: conflict_set.clone(),
|
||||
conflict_set,
|
||||
_subscription: subscription,
|
||||
}
|
||||
});
|
||||
|
@ -437,7 +437,6 @@ fn render_conflict_buttons(
|
|||
Button::new("both", "Use Both")
|
||||
.label_size(LabelSize::Small)
|
||||
.on_click({
|
||||
let editor = editor.clone();
|
||||
let conflict = conflict.clone();
|
||||
let ours = conflict.ours.clone();
|
||||
let theirs = conflict.theirs.clone();
|
||||
|
|
|
@ -1467,7 +1467,6 @@ impl GitPanel {
|
|||
.read(cx)
|
||||
.as_singleton()
|
||||
.unwrap()
|
||||
.clone()
|
||||
}
|
||||
|
||||
fn toggle_staged_for_selected(
|
||||
|
@ -3207,7 +3206,7 @@ impl GitPanel {
|
|||
Some(ContextMenu::build(window, cx, |context_menu, _, _| {
|
||||
context_menu
|
||||
.when_some(keybinding_target.clone(), |el, keybinding_target| {
|
||||
el.context(keybinding_target.clone())
|
||||
el.context(keybinding_target)
|
||||
})
|
||||
.when(has_previous_commit, |this| {
|
||||
this.toggleable_entry(
|
||||
|
@ -3387,7 +3386,7 @@ impl GitPanel {
|
|||
let enable_coauthors = self.render_co_authors(cx);
|
||||
|
||||
let editor_focus_handle = self.commit_editor.focus_handle(cx);
|
||||
let expand_tooltip_focus_handle = editor_focus_handle.clone();
|
||||
let expand_tooltip_focus_handle = editor_focus_handle;
|
||||
|
||||
let branch = active_repository.read(cx).branch.clone();
|
||||
let head_commit = active_repository.read(cx).head_commit.clone();
|
||||
|
@ -3416,7 +3415,7 @@ impl GitPanel {
|
|||
display_name,
|
||||
branch,
|
||||
head_commit,
|
||||
Some(git_panel.clone()),
|
||||
Some(git_panel),
|
||||
))
|
||||
.child(
|
||||
panel_editor_container(window, cx)
|
||||
|
@ -3567,7 +3566,7 @@ impl GitPanel {
|
|||
}),
|
||||
self.render_git_commit_menu(
|
||||
ElementId::Name(format!("split-button-right-{}", title).into()),
|
||||
Some(commit_tooltip_focus_handle.clone()),
|
||||
Some(commit_tooltip_focus_handle),
|
||||
cx,
|
||||
)
|
||||
.into_any_element(),
|
||||
|
@ -3633,7 +3632,7 @@ impl GitPanel {
|
|||
CommitView::open(
|
||||
commit.clone(),
|
||||
repo.clone(),
|
||||
workspace.clone().clone(),
|
||||
workspace.clone(),
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
|
@ -4341,7 +4340,7 @@ impl GitPanel {
|
|||
}
|
||||
})
|
||||
.child(
|
||||
self.entry_label(display_name.clone(), label_color)
|
||||
self.entry_label(display_name, label_color)
|
||||
.when(status.is_deleted(), |this| this.strikethrough()),
|
||||
),
|
||||
)
|
||||
|
@ -4690,7 +4689,7 @@ impl GitPanelMessageTooltip {
|
|||
author_email: details.author_email.clone(),
|
||||
commit_time: OffsetDateTime::from_unix_timestamp(details.commit_timestamp)?,
|
||||
message: Some(ParsedCommitMessage {
|
||||
message: details.message.clone(),
|
||||
message: details.message,
|
||||
..Default::default()
|
||||
}),
|
||||
};
|
||||
|
@ -4823,7 +4822,7 @@ impl RenderOnce for PanelRepoFooter {
|
|||
};
|
||||
|
||||
let truncated_branch_name = if branch_actual_len <= branch_display_len {
|
||||
branch_name.to_string()
|
||||
branch_name
|
||||
} else {
|
||||
util::truncate_and_trailoff(branch_name.trim_ascii(), branch_display_len)
|
||||
};
|
||||
|
@ -4836,7 +4835,7 @@ impl RenderOnce for PanelRepoFooter {
|
|||
|
||||
let repo_selector = PopoverMenu::new("repository-switcher")
|
||||
.menu({
|
||||
let project = project.clone();
|
||||
let project = project;
|
||||
move |window, cx| {
|
||||
let project = project.clone()?;
|
||||
Some(cx.new(|cx| RepositorySelector::new(project, rems(16.), window, cx)))
|
||||
|
@ -5007,10 +5006,7 @@ impl Component for PanelRepoFooter {
|
|||
div()
|
||||
.w(example_width)
|
||||
.overflow_hidden()
|
||||
.child(PanelRepoFooter::new_preview(
|
||||
active_repository(1).clone(),
|
||||
None,
|
||||
))
|
||||
.child(PanelRepoFooter::new_preview(active_repository(1), None))
|
||||
.into_any_element(),
|
||||
),
|
||||
single_example(
|
||||
|
@ -5019,7 +5015,7 @@ impl Component for PanelRepoFooter {
|
|||
.w(example_width)
|
||||
.overflow_hidden()
|
||||
.child(PanelRepoFooter::new_preview(
|
||||
active_repository(2).clone(),
|
||||
active_repository(2),
|
||||
Some(branch(unknown_upstream)),
|
||||
))
|
||||
.into_any_element(),
|
||||
|
@ -5030,7 +5026,7 @@ impl Component for PanelRepoFooter {
|
|||
.w(example_width)
|
||||
.overflow_hidden()
|
||||
.child(PanelRepoFooter::new_preview(
|
||||
active_repository(3).clone(),
|
||||
active_repository(3),
|
||||
Some(branch(no_remote_upstream)),
|
||||
))
|
||||
.into_any_element(),
|
||||
|
@ -5041,7 +5037,7 @@ impl Component for PanelRepoFooter {
|
|||
.w(example_width)
|
||||
.overflow_hidden()
|
||||
.child(PanelRepoFooter::new_preview(
|
||||
active_repository(4).clone(),
|
||||
active_repository(4),
|
||||
Some(branch(not_ahead_or_behind_upstream)),
|
||||
))
|
||||
.into_any_element(),
|
||||
|
@ -5052,7 +5048,7 @@ impl Component for PanelRepoFooter {
|
|||
.w(example_width)
|
||||
.overflow_hidden()
|
||||
.child(PanelRepoFooter::new_preview(
|
||||
active_repository(5).clone(),
|
||||
active_repository(5),
|
||||
Some(branch(behind_upstream)),
|
||||
))
|
||||
.into_any_element(),
|
||||
|
@ -5063,7 +5059,7 @@ impl Component for PanelRepoFooter {
|
|||
.w(example_width)
|
||||
.overflow_hidden()
|
||||
.child(PanelRepoFooter::new_preview(
|
||||
active_repository(6).clone(),
|
||||
active_repository(6),
|
||||
Some(branch(ahead_of_upstream)),
|
||||
))
|
||||
.into_any_element(),
|
||||
|
@ -5074,7 +5070,7 @@ impl Component for PanelRepoFooter {
|
|||
.w(example_width)
|
||||
.overflow_hidden()
|
||||
.child(PanelRepoFooter::new_preview(
|
||||
active_repository(7).clone(),
|
||||
active_repository(7),
|
||||
Some(branch(ahead_and_behind_upstream)),
|
||||
))
|
||||
.into_any_element(),
|
||||
|
|
|
@ -245,12 +245,12 @@ fn render_remote_button(
|
|||
}
|
||||
(0, 0) => None,
|
||||
(ahead, 0) => Some(remote_button::render_push_button(
|
||||
keybinding_target.clone(),
|
||||
keybinding_target,
|
||||
id,
|
||||
ahead,
|
||||
)),
|
||||
(ahead, behind) => Some(remote_button::render_pull_button(
|
||||
keybinding_target.clone(),
|
||||
keybinding_target,
|
||||
id,
|
||||
ahead,
|
||||
behind,
|
||||
|
@ -425,16 +425,9 @@ mod remote_button {
|
|||
let command = command.into();
|
||||
|
||||
if let Some(handle) = focus_handle {
|
||||
Tooltip::with_meta_in(
|
||||
label.clone(),
|
||||
Some(action),
|
||||
command.clone(),
|
||||
&handle,
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
Tooltip::with_meta_in(label, Some(action), command, &handle, window, cx)
|
||||
} else {
|
||||
Tooltip::with_meta(label.clone(), Some(action), command.clone(), window, cx)
|
||||
Tooltip::with_meta(label, Some(action), command, window, cx)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -457,7 +450,7 @@ mod remote_button {
|
|||
Some(ContextMenu::build(window, cx, |context_menu, _, _| {
|
||||
context_menu
|
||||
.when_some(keybinding_target.clone(), |el, keybinding_target| {
|
||||
el.context(keybinding_target.clone())
|
||||
el.context(keybinding_target)
|
||||
})
|
||||
.action("Fetch", git::Fetch.boxed_clone())
|
||||
.action("Fetch From", git::FetchFrom.boxed_clone())
|
||||
|
|
|
@ -242,7 +242,7 @@ impl ProjectDiff {
|
|||
TRACKED_NAMESPACE
|
||||
};
|
||||
|
||||
let path_key = PathKey::namespaced(namespace, entry.repo_path.0.clone());
|
||||
let path_key = PathKey::namespaced(namespace, entry.repo_path.0);
|
||||
|
||||
self.move_to_path(path_key, window, cx)
|
||||
}
|
||||
|
@ -448,10 +448,10 @@ impl ProjectDiff {
|
|||
let diff = diff.read(cx);
|
||||
let diff_hunk_ranges = diff
|
||||
.hunks_intersecting_range(Anchor::MIN..Anchor::MAX, &snapshot, cx)
|
||||
.map(|diff_hunk| diff_hunk.buffer_range.clone());
|
||||
.map(|diff_hunk| diff_hunk.buffer_range);
|
||||
let conflicts = conflict_addon
|
||||
.conflict_set(snapshot.remote_id())
|
||||
.map(|conflict_set| conflict_set.read(cx).snapshot().conflicts.clone())
|
||||
.map(|conflict_set| conflict_set.read(cx).snapshot().conflicts)
|
||||
.unwrap_or_default();
|
||||
let conflicts = conflicts.iter().map(|conflict| conflict.range.clone());
|
||||
|
||||
|
@ -737,7 +737,7 @@ impl Render for ProjectDiff {
|
|||
} else {
|
||||
None
|
||||
};
|
||||
let keybinding_focus_handle = self.focus_handle(cx).clone();
|
||||
let keybinding_focus_handle = self.focus_handle(cx);
|
||||
el.child(
|
||||
v_flex()
|
||||
.gap_1()
|
||||
|
|
|
@ -48,7 +48,7 @@ impl TextDiffView {
|
|||
|
||||
let selection_data = source_editor.update(cx, |editor, cx| {
|
||||
let multibuffer = editor.buffer().read(cx);
|
||||
let source_buffer = multibuffer.as_singleton()?.clone();
|
||||
let source_buffer = multibuffer.as_singleton()?;
|
||||
let selections = editor.selections.all::<Point>(cx);
|
||||
let buffer_snapshot = source_buffer.read(cx);
|
||||
let first_selection = selections.first()?;
|
||||
|
@ -259,7 +259,7 @@ async fn update_diff_buffer(
|
|||
let source_buffer_snapshot = source_buffer.read_with(cx, |buffer, _| buffer.snapshot())?;
|
||||
|
||||
let base_buffer_snapshot = clipboard_buffer.read_with(cx, |buffer, _| buffer.snapshot())?;
|
||||
let base_text = base_buffer_snapshot.text().to_string();
|
||||
let base_text = base_buffer_snapshot.text();
|
||||
|
||||
let diff_snapshot = cx
|
||||
.update(|cx| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue