From ddff089286fc76eef08cb21d4a5de9fa3ed7e8f8 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Fri, 7 Apr 2023 12:44:22 +0900 Subject: [PATCH] revset: do not evaluate roots() candidates three times --- lib/src/default_revset_engine.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/src/default_revset_engine.rs b/lib/src/default_revset_engine.rs index bbacc0840..2a76b5d62 100644 --- a/lib/src/default_revset_engine.rs +++ b/lib/src/default_revset_engine.rs @@ -688,8 +688,10 @@ impl<'index, 'heads> EvaluationContext<'index, 'heads> { .revset_for_commit_ids(&self.composite_index.heads(&mut candidate_ids.iter()))) } RevsetExpression::Roots(candidates) => { - let candidate_set = self.evaluate(candidates)?; - let (_, filled) = self.collect_dag_range(&*candidate_set, &*candidate_set); + let candidate_set = EagerRevset { + index_entries: self.evaluate(candidates)?.iter().collect(), + }; + let (_, filled) = self.collect_dag_range(&candidate_set, &candidate_set); let mut index_entries = vec![]; for candidate in candidate_set.iter() { if !candidate