improve performance on diffing giant files (#96)

This commit is contained in:
Stephan Dilly 2020-05-29 09:44:11 +02:00
parent ff6712246a
commit 732690da1d
2 changed files with 3 additions and 3 deletions

View File

@ -71,7 +71,7 @@ pub struct FileDiff {
/// list of hunks /// list of hunks
pub hunks: Vec<Hunk>, pub hunks: Vec<Hunk>,
/// lines total summed up over hunks /// lines total summed up over hunks
pub lines: u16, pub lines: usize,
} }
pub(crate) fn get_diff_raw<'a>( pub(crate) fn get_diff_raw<'a>(
@ -144,7 +144,7 @@ pub fn get_diff(
header_hash: hash(header), header_hash: hash(header),
lines: lines.clone(), lines: lines.clone(),
}); });
res.lines += lines.len() as u16; res.lines += lines.len();
}; };
let mut put = |hunk: Option<DiffHunk>, line: git2::DiffLine| { let mut put = |hunk: Option<DiffHunk>, line: git2::DiffLine| {

View File

@ -172,7 +172,7 @@ impl DiffComponent {
if Self::hunk_visible(hunk_min, hunk_max, min, max) { if Self::hunk_visible(hunk_min, hunk_max, min, max) {
for (i, line) in hunk.lines.iter().enumerate() { for (i, line) in hunk.lines.iter().enumerate() {
if line_cursor >= min { if line_cursor >= min && line_cursor <= max {
Self::add_line( Self::add_line(
&mut res, &mut res,
width, width,