History

[git-diff] enforce greater restraint when using path-ids

That way, the trait impls can optimize access to their data structures.

Sebastian Thiel committed 5 years ago

Commit ad893201 parent 684de4b3 files · +19 −19Browse files

Showing the changes to git-diff/src/tree/changes.rs (1 of 3 files). Show all

Unified · Split

git-diff/src/tree/changes.rs+12−12
@@ -75,14 +75,14 @@ impl<'a> tree::Changes<'a> { · 74 unmodified lines
7575 match (lhs_entries.next(), rhs_entries.next()) {
7676 (None, None) => {
7777 match state.trees.pop_front() {
78− Some((None, Some(rhs))) => {
79− delegate.set_current_path(rhs.parent_path_id.clone());
78+ Some((None, Some(mut rhs))) => {
79+ delegate.set_current_path(rhs.parent_path_id.take().expect("path-id is set"));
8080 rhs_entries = peekable(
8181 locate(&rhs.tree_id, &mut state.buf2).ok_or(Error::NotFound { oid: rhs.tree_id })?,
8282 );
8383 }
84− Some((Some(lhs), Some(rhs))) => {
85− delegate.set_current_path(lhs.parent_path_id.clone());
84+ Some((Some(mut lhs), Some(rhs))) => {
85+ delegate.set_current_path(lhs.parent_path_id.take().expect("path-id is set in lhs"));
8686 lhs_entries = peekable(
8787 locate(&lhs.tree_id, &mut state.buf1).ok_or(Error::NotFound { oid: lhs.tree_id })?,
8888 );
@@ -90,8 +90,8 @@ impl<'a> tree::Changes<'a> { · 1 unmodified line
9090 locate(&rhs.tree_id, &mut state.buf2).ok_or(Error::NotFound { oid: rhs.tree_id })?,
9191 );
9292 }
93− Some((Some(lhs), None)) => {
94− delegate.set_current_path(lhs.parent_path_id.clone());
93+ Some((Some(mut lhs), None)) => {
94+ delegate.set_current_path(lhs.parent_path_id.take().expect("path-id is set"));
9595 lhs_entries = peekable(
9696 locate(&lhs.tree_id, &mut state.buf1).ok_or(Error::NotFound { oid: lhs.tree_id })?,
9797 );
@@ -144,7 +144,7 @@ fn delete_entry_schedule_recursion<R: tree::Visit>( · 46 unmodified lines
144144 queue.push_back((
145145 Some(TreeInfo {
146146 tree_id: entry.oid.to_owned(),
147− parent_path_id: path_id,
147+ parent_path_id: Some(path_id),
148148 }),
149149 None,
150150 ));
@@ -174,7 +174,7 @@ fn add_entry_schedule_recursion<R: tree::Visit>( · 23 unmodified lines
174174 None,
175175 Some(TreeInfo {
176176 tree_id: entry.oid.to_owned(),
177− parent_path_id: path_id,
177+ parent_path_id: Some(path_id),
178178 }),
179179 ))
180180 }
@@ -285,11 +285,11 @@ fn handle_lhs_and_rhs_with_equal_filenames<R: tree::Visit>( · 104 unmodified lines
285285 queue.push_back((
286286 Some(TreeInfo {
287287 tree_id: lhs.oid.to_owned(),
288− parent_path_id: path_id.clone(),
288+ parent_path_id: Some(path_id),
289289 }),
290290 Some(TreeInfo {
291291 tree_id: rhs.oid.to_owned(),
292− parent_path_id: path_id,
292+ parent_path_id: None,
293293 }),
294294 ));
295295 }
@@ -317,7 +317,7 @@ fn handle_lhs_and_rhs_with_equal_filenames<R: tree::Visit>( · 21 unmodified lines
317317 None,
318318 Some(TreeInfo {
319319 tree_id: rhs.oid.to_owned(),
320− parent_path_id: path_id,
320+ parent_path_id: Some(path_id),
321321 }),
322322 ));
323323 }
@@ -344,7 +344,7 @@ fn handle_lhs_and_rhs_with_equal_filenames<R: tree::Visit>( · 20 unmodified lines
344344 queue.push_back((
345345 Some(TreeInfo {
346346 tree_id: lhs.oid.to_owned(),
347− parent_path_id: path_id,
347+ parent_path_id: Some(path_id),
348348 }),
349349 None,
350350 ));

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t