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
Showing the changes to crates/buffer_diff/src/buffer_diff.rs (1 of 306 files). Show all
Unified · Split
| @@ -175,12 +175,8 @@ impl BufferDiffSnapshot { · 174 unmodified lines | |||
| 175 | if let Some(text) = &base_text { | 175 | if let Some(text) = &base_text { |
| 176 | let base_text_rope = Rope::from(text.as_str()); | 176 | let base_text_rope = Rope::from(text.as_str()); |
| 177 | base_text_pair = Some((text.clone(), base_text_rope.clone())); | 177 | base_text_pair = Some((text.clone(), base_text_rope.clone())); |
| 178 | let snapshot = language::Buffer::build_snapshot( | 178 | let snapshot = |
| 179 | base_text_rope, | 179 | language::Buffer::build_snapshot(base_text_rope, language, language_registry, cx); |
| 180 | language.clone(), | ||
| 181 | language_registry.clone(), | ||
| 182 | cx, | ||
| 183 | ); | ||
| 184 | base_text_snapshot = cx.background_spawn(snapshot); | 180 | base_text_snapshot = cx.background_spawn(snapshot); |
| 185 | base_text_exists = true; | 181 | base_text_exists = true; |
| 186 | } else { | 182 | } else { |
| @@ -957,7 +953,7 @@ impl BufferDiff { · 770 unmodified lines | |||
| 957 | .buffer_range | 953 | .buffer_range |
| 958 | .start; | 954 | .start; |
| 959 | let end = self | 955 | let end = self |
| 960 | .hunks_intersecting_range_rev(range.clone(), buffer) | 956 | .hunks_intersecting_range_rev(range, buffer) |
| 961 | .next()? | 957 | .next()? |
| 962 | .buffer_range | 958 | .buffer_range |
| 963 | .end; | 959 | .end; |
| @@ -1441,7 +1437,7 @@ mod tests { · 477 unmodified lines | |||
| 1441 | .unindent(); | 1437 | .unindent(); |
| 1442 | 1438 | ||
| 1443 | let buffer = Buffer::new(0, BufferId::new(1).unwrap(), buffer_text); | 1439 | 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); |
| 1445 | let mut uncommitted_diff = | 1441 | let mut uncommitted_diff = |
| 1446 | BufferDiffSnapshot::new_sync(buffer.clone(), head_text.clone(), cx); | 1442 | BufferDiffSnapshot::new_sync(buffer.clone(), head_text.clone(), cx); |
| 1447 | uncommitted_diff.secondary_diff = Some(Box::new(unstaged_diff)); | 1443 | uncommitted_diff.secondary_diff = Some(Box::new(unstaged_diff)); |