git: return early from import_refs() if no commits to abandon

This saves another 150ms needed to set up binary heap with ~4000 wanted
and unwanted heads.
This commit is contained in:
Yuya Nishihara 2023-06-15 17:48:20 +09:00
parent 5fda093481
commit 8b0c01d1e9

View file

@ -216,6 +216,9 @@ pub fn import_some_refs(
.filter_map(|(old_git_target, _)| old_git_target.as_ref().map(|target| target.adds()))
.flatten()
.collect_vec();
if hidable_git_heads.is_empty() {
return Ok(());
}
// We must remove non-existing commits from pinned_git_heads, as they could have
// come from branches which were never fetched.
let mut pinned_git_heads_set = HashSet::new();