Mercurial > hg
changeset 51228:61a6ef876efd
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).
author | Georges Racinet <georges.racinet@octobus.net> |
---|---|
date | Fri, 20 Oct 2023 08:54:49 +0200 |
parents | e553cd209215 |
children | 1b23aaf5eb7b |
files | rust/hg-core/src/revlog/index.rs |
diffstat | 1 files changed, 6 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- 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 {