diff --git a/rust/hg-core/src/discovery.rs b/rust/hg-core/src/discovery.rs --- a/rust/hg-core/src/discovery.rs +++ b/rust/hg-core/src/discovery.rs @@ -256,6 +256,11 @@ &mut self, missing: impl IntoIterator, ) -> Result<(), GraphError> { + let missing: VecDeque = missing.into_iter().collect(); + if missing.is_empty() { + return Ok(()); + } + self.mutate_undecided( |oc| oc.compute_undecided(), |wu| wu.add_missing_revisions(missing), @@ -431,20 +436,14 @@ /// /// # Performance note /// - /// Except in the most trivial case, the first call of this method has - /// the side effect of computing `self.undecided` set for the first time, - /// and the related caches it might need for efficiency of its internal - /// computation. This is typically faster if more information is - /// available in `self.common`. Therefore, for good performance, the - /// caller should avoid calling this too early. + /// `tovisit` is provided as a `VecDeque` already so that a potential + /// caller from `PartialDiscovery` can avoid the undecided set in case + /// it turns out to be empty (hence restrain + /// from performing the transition to `WithUndecided`) pub fn add_missing_revisions( &mut self, - missing: impl IntoIterator, + mut tovisit: VecDeque, ) -> Result<(), GraphError> { - let mut tovisit: VecDeque = missing.into_iter().collect(); - if tovisit.is_empty() { - return Ok(()); - } self.ensure_children_cache()?; let children = self.children_cache.as_ref().unwrap(); let mut seen: HashSet = HashSet::new(); @@ -773,7 +772,7 @@ // of `undecided`, let's check that, force the mutation and // ask for them assert_disco_is_only_commons(&disco); - disco.add_missing_revisions(Vec::new())?; + disco.mutate_undecided(|oc| oc.compute_undecided(), |_| Ok(()))?; assert_disco_is_b(&disco); assert_eq!(sorted_undecided(&disco), vec![5, 8, 10, 13]); assert_eq!(disco.stats().undecided, Some(4));