From 72271c0d1f7d9ee0c66660904a877cc0a1c5f04c Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sat, 20 May 2023 08:25:41 +0900 Subject: [PATCH] repo: micro-optimize add_head() to not instantiate indexed commit object --- lib/src/repo.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/src/repo.rs b/lib/src/repo.rs index 69c7837b0..227070814 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -935,9 +935,10 @@ impl MutableRepo { |commit: &Commit| commit.id().clone(), |commit: &Commit| -> Vec { commit - .parents() - .into_iter() - .filter(|parent| !self.index().has_id(parent.id())) + .parent_ids() + .iter() + .filter(|id| !self.index().has_id(id)) + .map(|id| self.store().get_commit(id).unwrap()) .collect() }, );