Skip to content

Commit 3c8eb7e

Browse files
author
Stephan Dilly
authored
improve files in diff speed (#979)
closes #976
1 parent fa7cd37 commit 3c8eb7e

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
### Fixed
1818
- honor options (for untracked files) in `stage_all` command ([#933](https://github.com/extrawurst/gitui/issues/933))
19+
- improved file diff speed dramatically ([#976](https://github.com/extrawurst/gitui/issues/976))
1920

2021
## [0.18] - 2021-10-11
2122

asyncgit/src/sync/commit_files.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use super::{stash::is_stash_commit, utils::repo, CommitId};
44
use crate::{
55
error::Error, error::Result, StatusItem, StatusItemType,
66
};
7-
use git2::{Diff, DiffDelta, DiffOptions, Repository};
7+
use git2::{Diff, DiffOptions, Repository};
88
use scopetime::scope_time;
99

1010
/// get all files that are part of a commit
@@ -23,24 +23,21 @@ pub fn get_commit_files(
2323
get_commit_diff(&repo, id, None)?
2424
};
2525

26-
let mut res = Vec::new();
26+
let res = diff
27+
.deltas()
28+
.map(|delta| {
29+
let status = StatusItemType::from(delta.status());
2730

28-
diff.foreach(
29-
&mut |delta: DiffDelta<'_>, _progress| {
30-
res.push(StatusItem {
31+
StatusItem {
3132
path: delta
3233
.new_file()
3334
.path()
3435
.map(|p| p.to_str().unwrap_or("").to_string())
3536
.unwrap_or_default(),
36-
status: StatusItemType::from(delta.status()),
37-
});
38-
true
39-
},
40-
None,
41-
None,
42-
None,
43-
)?;
37+
status,
38+
}
39+
})
40+
.collect::<Vec<_>>();
4441

4542
Ok(res)
4643
}

0 commit comments

Comments
 (0)