From 8b0c01d1e9afbc2fe4a12113436e9192a4e5dd33 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Thu, 15 Jun 2023 17:48:20 +0900 Subject: [PATCH] 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. --- lib/src/git.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/src/git.rs b/lib/src/git.rs index ec569bd31..c4548bbcd 100644 --- a/lib/src/git.rs +++ b/lib/src/git.rs @@ -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();