From 9818353349c5e89fec4c4f02b6ea58dc4b2fc4d4 Mon Sep 17 00:00:00 2001 From: Joscha Date: Mon, 23 Jan 2023 13:04:10 +0100 Subject: [PATCH] Improve performance on larger repos --- src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 843b11a..1fdd769 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,13 +32,16 @@ fn count_lines(repo: &Repository, commit: &Commit) -> anyhow::Result { fn main() -> anyhow::Result<()> { let args = Args::parse(); - let repo = git_repository::discover(args.repo)?; + let mut repo = git_repository::discover(args.repo)?; + repo.object_cache_size(Some(100 * 1024 * 1024)); let commit = repo.head_commit()?; let mut lines = vec![]; for ancestor in commit.ancestors().all()? { let ancestor = repo.find_object(ancestor.unwrap())?.try_into_commit()?; - lines.push(count_lines(&repo, &ancestor)?); + let line_count = count_lines(&repo, &ancestor)?; + println!("{} {line_count}", ancestor.id); + lines.push(line_count); } let xmax = lines.len();