##// END OF EJS Templates
rust-ancestors: remove unreachable conditions from missing_ancestors()
Yuya Nishihara -
r41169:a1b3800c default
parent child Browse files
Show More
@@ -338,23 +338,13 b' impl<G: Graph> MissingAncestors<G> {'
338 }
338 }
339 continue;
339 continue;
340 }
340 }
341 // in Rust, one can't just use mutable variables assignation
342 // to be more straightforward. Instead of Python's
343 // thisvisit and othervisit, we'll differentiate with a boolean
344 let this_visit_is_revs;
345 if revs_visit.remove(&curr) {
341 if revs_visit.remove(&curr) {
346 missing.push(curr);
342 missing.push(curr);
347 this_visit_is_revs = true;
348 for p in self.graph.parents(curr)?.iter().cloned() {
343 for p in self.graph.parents(curr)?.iter().cloned() {
349 if p == NULL_REVISION {
344 if p == NULL_REVISION {
350 continue;
345 continue;
351 }
346 }
352 let in_other_visit = if this_visit_is_revs {
347 if bases_visit.contains(&p) || both_visit.contains(&p) {
353 bases_visit.contains(&p)
354 } else {
355 revs_visit.contains(&p)
356 };
357 if in_other_visit || both_visit.contains(&p) {
358 // p is implicitely in this_visit.
348 // p is implicitely in this_visit.
359 // This means p is or should be in bothvisit
349 // This means p is or should be in bothvisit
360 // TODO optim: hence if bothvisit, we look up twice
350 // TODO optim: hence if bothvisit, we look up twice
@@ -363,25 +353,15 b' impl<G: Graph> MissingAncestors<G> {'
363 both_visit.insert(p);
353 both_visit.insert(p);
364 } else {
354 } else {
365 // visit later
355 // visit later
366 if this_visit_is_revs {
356 revs_visit.insert(p);
367 revs_visit.insert(p);
368 } else {
369 bases_visit.insert(p);
370 }
371 }
357 }
372 }
358 }
373 } else if bases_visit.contains(&curr) {
359 } else if bases_visit.contains(&curr) {
374 this_visit_is_revs = false;
375 for p in self.graph.parents(curr)?.iter().cloned() {
360 for p in self.graph.parents(curr)?.iter().cloned() {
376 if p == NULL_REVISION {
361 if p == NULL_REVISION {
377 continue;
362 continue;
378 }
363 }
379 let in_other_visit = if this_visit_is_revs {
364 if revs_visit.contains(&p) || both_visit.contains(&p) {
380 bases_visit.contains(&p)
381 } else {
382 revs_visit.contains(&p)
383 };
384 if in_other_visit || both_visit.contains(&p) {
385 // p is implicitely in this_visit.
365 // p is implicitely in this_visit.
386 // This means p is or should be in bothvisit
366 // This means p is or should be in bothvisit
387 // TODO optim: hence if bothvisit, we look up twice
367 // TODO optim: hence if bothvisit, we look up twice
@@ -390,11 +370,7 b' impl<G: Graph> MissingAncestors<G> {'
390 both_visit.insert(p);
370 both_visit.insert(p);
391 } else {
371 } else {
392 // visit later
372 // visit later
393 if this_visit_is_revs {
373 bases_visit.insert(p);
394 revs_visit.insert(p);
395 } else {
396 bases_visit.insert(p);
397 }
398 }
374 }
399 }
375 }
400 } else {
376 } else {
General Comments 0
You need to be logged in to leave comments. Login now