Skip to content

Commit

Permalink
improve performance on diffing giant files (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Dilly committed May 29, 2020
1 parent ff67122 commit 732690d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions asyncgit/src/sync/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub struct FileDiff {
/// list of hunks
pub hunks: Vec<Hunk>,
/// lines total summed up over hunks
pub lines: u16,
pub lines: usize,
}

pub(crate) fn get_diff_raw<'a>(
Expand Down Expand Up @@ -144,7 +144,7 @@ pub fn get_diff(
header_hash: hash(header),
lines: lines.clone(),
});
res.lines += lines.len() as u16;
res.lines += lines.len();
};

let mut put = |hunk: Option<DiffHunk>, line: git2::DiffLine| {
Expand Down
2 changes: 1 addition & 1 deletion src/components/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl DiffComponent {

if Self::hunk_visible(hunk_min, hunk_max, min, max) {
for (i, line) in hunk.lines.iter().enumerate() {
if line_cursor >= min {
if line_cursor >= min && line_cursor <= max {
Self::add_line(
&mut res,
width,
Expand Down

0 comments on commit 732690d

Please sign in to comment.