# HG changeset patch # User Georges Racinet # Date 1697784889 -7200 # Node ID 61a6ef876efde761ecdfa416f3e6c81a33cc10d8 # Parent e553cd209215e6631c66f0ab2c13a227f101bce9 rust-index: simplification in find_gca_candidates() `parent_seen` can be made a mutable ref, making this part more obvious, not needing to be commented so much. The micro-optimization of avoiding the union if `parent_seen` and `current_seen` agree is pushed down in the `union()` method of the fast, `u64` based bit set implementation (in case it matters). diff -r e553cd209215 -r 61a6ef876efd rust/hg-core/src/revlog/index.rs --- a/rust/hg-core/src/revlog/index.rs Fri Oct 20 08:43:00 2023 +0200 +++ b/rust/hg-core/src/revlog/index.rs Fri Oct 20 08:54:49 2023 +0200 @@ -1141,7 +1141,7 @@ if parent == NULL_REVISION { continue; } - let parent_seen = &seen[parent.0 as usize]; + let parent_seen = &mut seen[parent.0 as usize]; if poison { // this block is logically equivalent to poisoning parent // and counting it as non interesting if it @@ -1149,18 +1149,12 @@ if !parent_seen.is_empty() && !parent_seen.is_poisoned() { interesting -= 1; } - seen[parent.0 as usize].poison(); + parent_seen.poison(); } else { - // Without the `interesting` accounting, this block would - // be logically equivalent to: parent_seen |= current_seen - // The parent counts as interesting if it was not already - // known to be an ancestor (would already have counted) if parent_seen.is_empty() { - seen[parent.0 as usize] = current_seen.clone(); interesting += 1; - } else if *parent_seen != current_seen { - seen[parent.0 as usize].union(¤t_seen); } + parent_seen.union(¤t_seen); } } @@ -1343,7 +1337,9 @@ } fn union(&mut self, other: &Self) { - (*self) |= *other; + if *self != *other { + (*self) |= *other; + } } fn is_full_range(&self, n: usize) -> bool {