Skip to content

Commit 3ac8be1

Browse files
committed
additional pass of refactoring, focus on the algorithm itself.
1 parent 63ee0f9 commit 3ac8be1

File tree

4 files changed

+199
-155
lines changed

4 files changed

+199
-155
lines changed

gix-blame/src/file/function.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{process_changes, Change, Offset, UnblamedHunk};
1+
use super::{process_changes, Change, UnblamedHunk};
22
use crate::{BlameEntry, Error, Outcome, Statistics};
33
use gix_diff::blob::intern::TokenSource;
44
use gix_hash::ObjectId;
@@ -83,11 +83,13 @@ where
8383
.count()
8484
};
8585

86-
let mut hunks_to_blame = vec![UnblamedHunk::new(
87-
0..num_lines_in_blamed as u32,
88-
suspect,
89-
Offset::Added(0),
90-
)];
86+
let mut hunks_to_blame = vec![{
87+
let range_in_blamed_file = 0..num_lines_in_blamed as u32;
88+
UnblamedHunk {
89+
range_in_blamed_file: range_in_blamed_file.clone(),
90+
suspects: [(suspect, range_in_blamed_file)].into(),
91+
}
92+
}];
9193

9294
let mut out = Vec::new();
9395
let mut diff_state = gix_diff::tree::State::default();
@@ -340,8 +342,10 @@ fn blob_changes(
340342

341343
match (!before.is_empty(), !after.is_empty()) {
342344
(_, true) => {
343-
self.hunks
344-
.push(Change::Added(after.start..after.end, before.end - before.start));
345+
self.hunks.push(Change::AddedOrReplaced(
346+
after.start..after.end,
347+
before.end - before.start,
348+
));
345349
}
346350
(true, false) => {
347351
self.hunks.push(Change::Deleted(after.start, before.end - before.start));

0 commit comments

Comments
 (0)