Patchwork [3,of,4] rust-ancestors: remove unreachable conditions from missing_ancestors()

login
register
mail settings
Submitter Yuya Nishihara
Date Jan. 6, 2019, 3:54 a.m.
Message ID <b1f97e06bd1e0923165a.1546746846@mimosa>
Download mbox | patch
Permalink /patch/37492/
State Accepted
Headers show

Comments

Yuya Nishihara - Jan. 6, 2019, 3:54 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1545223960 -32400
#      Wed Dec 19 21:52:40 2018 +0900
# Node ID b1f97e06bd1e0923165a16a6ba4894feadf735c0
# Parent  01b61bcb9abd37024369ce80eb2c585d47add935
rust-ancestors: remove unreachable conditions from missing_ancestors()

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
@@ -338,23 +338,13 @@  impl<G: Graph> MissingAncestors<G> {
                 }
                 continue;
             }
-            // in Rust, one can't just use mutable variables assignation
-            // to be more straightforward. Instead of Python's
-            // thisvisit and othervisit, we'll differentiate with a boolean
-            let this_visit_is_revs;
             if revs_visit.remove(&curr) {
                 missing.push(curr);
-                this_visit_is_revs = true;
                 for p in self.graph.parents(curr)?.iter().cloned() {
                     if p == NULL_REVISION {
                         continue;
                     }
-                    let in_other_visit = if this_visit_is_revs {
-                        bases_visit.contains(&p)
-                    } else {
-                        revs_visit.contains(&p)
-                    };
-                    if in_other_visit || both_visit.contains(&p) {
+                    if bases_visit.contains(&p) || both_visit.contains(&p) {
                         // p is implicitely in this_visit.
                         // This means p is or should be in bothvisit
                         // TODO optim: hence if bothvisit, we look up twice
@@ -363,25 +353,15 @@  impl<G: Graph> MissingAncestors<G> {
                         both_visit.insert(p);
                     } else {
                         // visit later
-                        if this_visit_is_revs {
-                            revs_visit.insert(p);
-                        } else {
-                            bases_visit.insert(p);
-                        }
+                        revs_visit.insert(p);
                     }
                 }
             } else if bases_visit.contains(&curr) {
-                this_visit_is_revs = false;
                 for p in self.graph.parents(curr)?.iter().cloned() {
                     if p == NULL_REVISION {
                         continue;
                     }
-                    let in_other_visit = if this_visit_is_revs {
-                        bases_visit.contains(&p)
-                    } else {
-                        revs_visit.contains(&p)
-                    };
-                    if in_other_visit || both_visit.contains(&p) {
+                    if revs_visit.contains(&p) || both_visit.contains(&p) {
                         // p is implicitely in this_visit.
                         // This means p is or should be in bothvisit
                         // TODO optim: hence if bothvisit, we look up twice
@@ -390,11 +370,7 @@  impl<G: Graph> MissingAncestors<G> {
                         both_visit.insert(p);
                     } else {
                         // visit later
-                        if this_visit_is_revs {
-                            revs_visit.insert(p);
-                        } else {
-                            bases_visit.insert(p);
-                        }
+                        bases_visit.insert(p);
                     }
                 }
             } else {