History

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

tidely committed 1 year ago

Commit 7bdc99a1 parent cf7c64d306 files · +805 −1102Browse files

Showing the changes to crates/buffer_diff/src/buffer_diff.rs (1 of 306 files). Show all

Unified · Split

crates/buffer_diff/src/buffer_diff.rs+4−8
@@ -175,12 +175,8 @@ impl BufferDiffSnapshot { · 174 unmodified lines
175175 if let Some(text) = &base_text {
176176 let base_text_rope = Rope::from(text.as_str());
177177 base_text_pair = Some((text.clone(), base_text_rope.clone()));
178− let snapshot = language::Buffer::build_snapshot(
179− base_text_rope,
180− language.clone(),
181− language_registry.clone(),
182− cx,
183− );
178+ let snapshot =
179+ language::Buffer::build_snapshot(base_text_rope, language, language_registry, cx);
184180 base_text_snapshot = cx.background_spawn(snapshot);
185181 base_text_exists = true;
186182 } else {
@@ -957,7 +953,7 @@ impl BufferDiff { · 770 unmodified lines
957953 .buffer_range
958954 .start;
959955 let end = self
960− .hunks_intersecting_range_rev(range.clone(), buffer)
956+ .hunks_intersecting_range_rev(range, buffer)
961957 .next()?
962958 .buffer_range
963959 .end;
@@ -1441,7 +1437,7 @@ mod tests { · 477 unmodified lines
14411437 .unindent();
14421438
14431439 let buffer = Buffer::new(0, BufferId::new(1).unwrap(), buffer_text);
1444− let unstaged_diff = BufferDiffSnapshot::new_sync(buffer.clone(), index_text.clone(), cx);
1440+ let unstaged_diff = BufferDiffSnapshot::new_sync(buffer.clone(), index_text, cx);
14451441 let mut uncommitted_diff =
14461442 BufferDiffSnapshot::new_sync(buffer.clone(), head_text.clone(), cx);
14471443 uncommitted_diff.secondary_diff = Some(Box::new(unstaged_diff));