From 891f6fa543877b8100842049cdcd20bd94ba5f83 Mon Sep 17 00:00:00 2001 From: Spenser Black Date: Thu, 2 Nov 2023 09:38:34 -0400 Subject: [PATCH] Simplify return types with aliases Co-authored-by: Ossama Hjaji --- src/info/git/mod.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/info/git/mod.rs b/src/info/git/mod.rs index 7b2c8b42b..9b0fb9c68 100644 --- a/src/info/git/mod.rs +++ b/src/info/git/mod.rs @@ -117,13 +117,15 @@ pub fn traverse_commit_graph(repo: &gix::Repository, options: &CliOptions) -> Re Ok(git_metrics) } +type NumberOfCommitsBySignature = HashMap; + fn get_author_channel( repo: &gix::Repository, num_threads: usize, bot_regex_pattern: &Option, mailmap: &gix::mailmap::Snapshot, ) -> ( - Vec>>>, + Vec>>, crossbeam_channel::Sender, ) { // we intentionally over-allocate threads a little as the main thread won't be very busy anyway @@ -140,7 +142,7 @@ fn get_author_channel( let bot_regex_pattern = bot_regex_pattern.clone(); let rx = rx.clone(); move || -> anyhow::Result<_> { - let mut number_of_commits_by_signature: HashMap = HashMap::new(); + let mut number_of_commits_by_signature = NumberOfCommitsBySignature::new(); // We are sure to see each object only once. repo.object_cache_size(0); while let Ok(commit_id) = rx.recv() { @@ -160,22 +162,22 @@ fn get_author_channel( (threads, tx) } +type NumberOfCommitsByFilepath = HashMap; +type ChurnPair = (NumberOfCommitsByFilepath, usize); + fn get_churn_channel( repo: &gix::Repository, has_commit_graph_traversal_ended: &Arc, total_number_of_commits: &Arc, churn_pool_size_opt: Option, -) -> Result<( - JoinHandle, usize)>>, - Sender, -)> { +) -> Result<(JoinHandle>, Sender)> { let (tx, rx) = channel::(); let thread = std::thread::spawn({ let repo = repo.clone(); let has_commit_graph_traversal_ended = has_commit_graph_traversal_ended.clone(); let total_number_of_commits = total_number_of_commits.clone(); move || -> Result<_> { - let mut number_of_commits_by_file_path: HashMap = HashMap::new(); + let mut number_of_commits_by_file_path = NumberOfCommitsByFilepath::new(); let mut number_of_diffs_computed = 0; while let Ok(commit_id) = rx.recv() { let commit = repo.find_object(commit_id)?.into_commit();