Skip to content

Commit

Permalink
adapt to changes in git-diff for a 2x speedup when calculating line…
Browse files Browse the repository at this point in the history
… changes
  • Loading branch information
Byron committed Oct 28, 2022
1 parent c6f92c1 commit 296f3b6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
27 changes: 10 additions & 17 deletions gitoxide-core/src/hours/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,24 +228,17 @@ where
if let Some(Ok(diff)) =
is_text_file.then(|| change.event.diff()).flatten()
{
use git::diff::lines::similar::ChangeTag::*;
let mut nl = 0;
for change in diff
.text(git::diff::lines::Algorithm::Myers)
.iter_all_changes()
{
match change.tag() {
Delete => {
lines.removed += 1;
nl += 1;
}
Insert => {
lines.added += 1;
nl += 1
}
Equal => {}
}
}
let counts = diff.lines(
git::diff::text::Algorithm::Myers,
|_| {
git::diff::text::imara::sink::Counter::default()
},
);
nl += counts.insertions as usize
+ counts.removals as usize;
lines.added += counts.insertions as usize;
lines.removed += counts.removals as usize;
if let Some(c) = lines_counter.as_ref() {
c.fetch_add(nl, Ordering::SeqCst);
}
Expand Down
4 changes: 4 additions & 0 deletions src/plumbing/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ static GIT_CONFIG: &[Record] = &[
deviation: None,
},
},
Record {
config: "core.eol",
usage: Planned {note: Some("needed for filters, but also for doing diffs correctly")}
},
Record {
config: "core.filesRefLockTimeout",
usage: InModule {name: "config::cache::access", deviation: None},
Expand Down

0 comments on commit 296f3b6

Please sign in to comment.