So rayon doesn't give perfect scaling here, but it's worth it.
Unified · Split
| @@ -72,30 +72,20 @@ fn main() -> anyhow::Result<()> { · 71 unmodified lines | ||
| 72 | 72 | |
| 73 | 73 | eprintln!("Getting all commit data…"); |
| 74 | 74 | let start = Instant::now(); |
| 75 | + let commits_wanted = all_commits.len(); | |
| 75 | 76 | #[allow(clippy::redundant_closure)] |
| 76 | 77 | let mut all_commits: Vec<CommitInfo> = all_commits |
| 77 | − .into_par_iter() | |
| 78 | − .map(|commit_data: Vec<u8>| { | |
| 78 | + .into_iter() | |
| 79 | + .filter_map(|commit_data: Vec<u8>| { | |
| 79 | 80 | git_object::immutable::CommitIter::from_bytes(&commit_data) |
| 80 | 81 | .signatures() |
| 81 | 82 | .next() |
| 82 | 83 | .map(|author| git_object::mutable::Signature::from(author)) |
| 83 | 84 | }) |
| 84 | − .try_fold( | |
| 85 | − || Vec::new(), | |
| 86 | − |mut out: Vec<_>, item| { | |
| 87 | − out.push(item?); | |
| 88 | − Some(out) | |
| 89 | − }, | |
| 90 | − ) | |
| 91 | − .try_reduce( | |
| 92 | − || Vec::new(), | |
| 93 | − |mut out, vec| { | |
| 94 | − out.extend(vec.into_iter()); | |
| 95 | − Some(out) | |
| 96 | − }, | |
| 97 | − ) | |
| 98 | − .ok_or_else(|| anyhow!("An error occurred when decoding commits - one commit could not be parsed"))?; | |
| 85 | + .collect::<Vec<_>>(); | |
| 86 | + if all_commits.len() != commits_wanted { | |
| 87 | + bail!("An error occurred when decoding commits - one commit could not be parsed"); | |
| 88 | + } | |
| 99 | 89 | let elapsed = start.elapsed(); |
| 100 | 90 | eprintln!( |
| 101 | 91 | "Obtained {} commits in {:?} ({:0.0} commits/s)", |