@@ -225,6 +225,12 @@ impl UnblamedHunk {
225225 }
226226 }
227227
228+ fn shift_by ( & self , offset : Offset ) -> Self {
229+ let combined_offset = self . offset ( ) + offset;
230+
231+ Self :: new ( self . range_in_blamed_file . clone ( ) , combined_offset)
232+ }
233+
228234 fn offset ( & self ) -> Offset {
229235 if self . range_in_blamed_file . start > self . range_in_destination . start {
230236 Offset :: Added ( self . range_in_blamed_file . start - self . range_in_destination . start )
@@ -327,13 +333,7 @@ pub fn process_change(
327333 // <--------> (hunk)
328334 // <-------> (unchanged)
329335
330- let line_range_in_next_destination =
331- LineRange :: with_offset ( hunk. range_in_destination . clone ( ) , * offset_in_destination) ;
332-
333- new_hunks_to_blame. push ( UnblamedHunk :: from_destination (
334- line_range_in_next_destination. into ( ) ,
335- hunk. offset ( ) + * offset_in_destination,
336- ) ) ;
336+ new_hunks_to_blame. push ( hunk. shift_by ( * offset_in_destination) ) ;
337337
338338 ( None , Some ( Change :: Unchanged ( unchanged) ) )
339339 }
@@ -360,13 +360,7 @@ pub fn process_change(
360360 // <---> (hunk)
361361 // <----------> (unchanged)
362362
363- let line_range_in_next_destination =
364- LineRange :: with_offset ( hunk. range_in_destination . clone ( ) , * offset_in_destination) ;
365-
366- new_hunks_to_blame. push ( UnblamedHunk :: from_destination (
367- line_range_in_next_destination. into ( ) ,
368- hunk. offset ( ) + * offset_in_destination,
369- ) ) ;
363+ new_hunks_to_blame. push ( hunk. shift_by ( * offset_in_destination) ) ;
370364
371365 ( None , Some ( Change :: Unchanged ( unchanged. clone ( ) ) ) )
372366 }
@@ -492,13 +486,7 @@ pub fn process_change(
492486 // <--> (hunk)
493487 // <----> (added)
494488
495- let line_range_in_next_destination =
496- LineRange :: with_offset ( hunk. range_in_destination . clone ( ) , * offset_in_destination) ;
497-
498- new_hunks_to_blame. push ( UnblamedHunk :: from_destination (
499- line_range_in_next_destination. into ( ) ,
500- hunk. offset ( ) + * offset_in_destination,
501- ) ) ;
489+ new_hunks_to_blame. push ( hunk. shift_by ( * offset_in_destination) ) ;
502490
503491 ( None , Some ( Change :: Added ( added. clone ( ) , number_of_lines_deleted) ) )
504492 } else {
@@ -553,13 +541,7 @@ pub fn process_change(
553541 // <---> (hunk)
554542 // | (line_number_in_destination)
555543
556- let line_range_in_next_destination =
557- LineRange :: with_offset ( hunk. range_in_destination . clone ( ) , * offset_in_destination) ;
558-
559- new_hunks_to_blame. push ( UnblamedHunk :: from_destination (
560- line_range_in_next_destination. into ( ) ,
561- hunk. offset ( ) + * offset_in_destination,
562- ) ) ;
544+ new_hunks_to_blame. push ( hunk. shift_by ( * offset_in_destination) ) ;
563545
564546 (
565547 None ,
@@ -568,10 +550,7 @@ pub fn process_change(
568550 }
569551 }
570552 ( Some ( hunk) , None ) => {
571- new_hunks_to_blame. push ( UnblamedHunk :: new (
572- hunk. range_in_blamed_file . clone ( ) ,
573- hunk. offset ( ) + * offset_in_destination,
574- ) ) ;
553+ new_hunks_to_blame. push ( hunk. shift_by ( * offset_in_destination) ) ;
575554
576555 ( None , None )
577556 }
0 commit comments