@@ -357,10 +357,8 @@ fn process_changes(
357
357
358
358
impl UnblamedHunk {
359
359
fn shift_by ( mut self , suspect : ObjectId , offset : Offset ) -> Self {
360
- if let Some ( position) = self . suspects . iter ( ) . position ( |entry| entry. 0 == suspect) {
361
- if let Some ( ( _, ref mut range_in_suspect) ) = self . suspects . get_mut ( position) {
362
- * range_in_suspect = range_in_suspect. shift_by ( offset) ;
363
- }
360
+ if let Some ( entry) = self . suspects . iter_mut ( ) . find ( |entry| entry. 0 == suspect) {
361
+ entry. 1 = entry. 1 . shift_by ( offset) ;
364
362
}
365
363
self
366
364
}
@@ -407,20 +405,16 @@ impl UnblamedHunk {
407
405
/// This is like [`Self::pass_blame()`], but easier to use in places where the 'passing' is
408
406
/// done 'inline'.
409
407
fn passed_blame ( mut self , from : ObjectId , to : ObjectId ) -> Self {
410
- if let Some ( position) = self . suspects . iter ( ) . position ( |entry| entry. 0 == from) {
411
- if let Some ( ( ref mut commit_id, _) ) = self . suspects . get_mut ( position) {
412
- * commit_id = to;
413
- }
408
+ if let Some ( entry) = self . suspects . iter_mut ( ) . find ( |entry| entry. 0 == from) {
409
+ entry. 0 = to;
414
410
}
415
411
self
416
412
}
417
413
418
414
/// Transfer all ranges from the commit at `from` to the commit at `to`.
419
415
fn pass_blame ( & mut self , from : ObjectId , to : ObjectId ) {
420
- if let Some ( position) = self . suspects . iter ( ) . position ( |entry| entry. 0 == from) {
421
- if let Some ( ( ref mut commit_id, _) ) = self . suspects . get_mut ( position) {
422
- * commit_id = to;
423
- }
416
+ if let Some ( entry) = self . suspects . iter_mut ( ) . find ( |entry| entry. 0 == from) {
417
+ entry. 0 = to;
424
418
}
425
419
}
426
420
0 commit comments