From 37cf6a839580e3388dab2a43ac529198a389adb9 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 14 Feb 2021 18:53:52 -0800 Subject: [PATCH] transaction: don't walk to root when adding on top of non-head I don't know why I made the walk stop at heads instead of indexed commits before. Perhaps I did it because it's cheap to check in the set of head. However, it gets very expensive to walk all the way back to the root if the parents are not in the set of heads. --- lib/src/transaction.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/src/transaction.rs b/lib/src/transaction.rs index d9b008685..f0cffca96 100644 --- a/lib/src/transaction.rs +++ b/lib/src/transaction.rs @@ -145,6 +145,7 @@ impl<'r> Transaction<'r> { mut_repo.view_mut().add_head(head); mut_repo.evolution_mut().add_commit(head); } else { + let index = mut_repo.index(); let missing_commits = topo_order_reverse( vec![head.clone()], Box::new(|commit: &Commit| commit.id().clone()), @@ -152,7 +153,7 @@ impl<'r> Transaction<'r> { commit .parents() .into_iter() - .filter(|parent| !current_heads.contains(parent.id())) + .filter(|parent| !index.has_id(parent.id())) .collect() }), );