Patchwork D5942: rust: less set lookups in AncestorsIterator

login
register
mail settings
Submitter phabricator
Date Feb. 16, 2019, 3:34 a.m.
Message ID <4a9340ebd1374ccd8d15992759f8fe25@localhost.localdomain>
Download mbox | patch
Permalink /patch/38787/
State Not Applicable
Headers show

Comments

phabricator - Feb. 16, 2019, 3:34 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG70827ebba453: rust: less set lookups in AncestorsIterator (authored by gracinet, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5942?vs=14039&id=14124

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

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

CHANGE DETAILS




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

Patch

diff --git a/rust/hg-core/src/ancestors.rs b/rust/hg-core/src/ancestors.rs
--- a/rust/hg-core/src/ancestors.rs
+++ b/rust/hg-core/src/ancestors.rs
@@ -79,8 +79,7 @@ 
 
     #[inline]
     fn conditionally_push_rev(&mut self, rev: Revision) {
-        if self.stoprev <= rev && !self.seen.contains(&rev) {
-            self.seen.insert(rev);
+        if self.stoprev <= rev && self.seen.insert(rev) {
             self.visit.push(rev);
         }
     }
@@ -154,11 +153,10 @@ 
             Ok(ps) => ps,
             Err(e) => return Some(Err(e)),
         };
-        if p1 < self.stoprev || self.seen.contains(&p1) {
+        if p1 < self.stoprev || !self.seen.insert(p1) {
             self.visit.pop();
         } else {
             *(self.visit.peek_mut().unwrap()) = p1;
-            self.seen.insert(p1);
         };
 
         self.conditionally_push_rev(p2);