Patchwork D6429: rust-discovery: optimization of add commons/missings for empty arguments

login
register
mail settings
Submitter phabricator
Date June 12, 2019, 6:17 p.m.
Message ID <b098a5eb0cd028f00b3cb2de3825aebd@localhost.localdomain>
Download mbox | patch
Permalink /patch/40460/
State Not Applicable
Headers show

Comments

phabricator - June 12, 2019, 6:17 p.m.
gracinet edited the summary of this revision.
gracinet retitled this revision from "rust-discovery: avoid useless calls to addcommons/addmissings" to "rust-discovery: optimization of add commons/missings for empty arguments".
gracinet updated this revision to Diff 15472.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6429?vs=15229&id=15472

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6429/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D6429

AFFECTED FILES
  rust/hg-core/src/discovery.rs

CHANGE DETAILS




To: gracinet, #hg-reviewers, kevincox
Cc: durin42, kevincox, mercurial-devel

Patch

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
@@ -220,9 +220,13 @@ 
         &mut self,
         common: impl IntoIterator<Item = Revision>,
     ) -> Result<(), GraphError> {
+        let before_len = self.common.get_bases().len();
         self.common.add_bases(common);
+        if self.common.get_bases().len() == before_len {
+            return Ok(())
+        }
         if let Some(ref mut undecided) = self.undecided {
-            self.common.remove_ancestors_from(undecided)?;
+                self.common.remove_ancestors_from(undecided)?;
         }
         Ok(())
     }
@@ -240,11 +244,11 @@ 
         &mut self,
         missing: impl IntoIterator<Item = Revision>,
     ) -> Result<(), GraphError> {
+        let mut tovisit: VecDeque<Revision> = missing.into_iter().collect();
         self.ensure_children_cache()?;
         self.ensure_undecided()?;  // for safety of possible future refactors
         let children = self.children_cache.as_ref().unwrap();
         let mut seen: HashSet<Revision> = HashSet::new();
-        let mut tovisit: VecDeque<Revision> = missing.into_iter().collect();
         let undecided_mut = self.undecided.as_mut().unwrap();
         while let Some(rev) = tovisit.pop_front() {
             if !self.missing.insert(rev) {