Mercurial > hg
diff rust/hg-core/src/dagops.rs @ 41717:9060af281be7
rust: itering less on MissingAncestors.bases for max()
Instead of iterating on the whole `self.bases` each time to find
its max, we keep the latter in a separate member attribute and
keep it up to date in `add_bases()`
On a perfdiscovery done on PyPy, with repos prepared with
`contrib/discovery-helper.sh 50 100`, this gives a slight
improvement (around 0.5% on wall time, but 10% on CPU)
before:
! wall 0.172801 comb 0.180000 user 0.180000 sys 0.000000 (median of 541)
after:
! wall 0.171798 comb 0.160000 user 0.160000 sys 0.000000 (median of 551)
(perf command run time upped because of bigger variability during this test).
Differential Revision: https://phab.mercurial-scm.org/D5945
author | Georges Racinet <georges.racinet@octobus.net> |
---|---|
date | Mon, 04 Feb 2019 19:46:57 +0100 |
parents | 47881d2a9d99 |
children | 3bdb21bbf791 |
line wrap: on
line diff
--- a/rust/hg-core/src/dagops.rs Tue Feb 05 10:28:32 2019 +0100 +++ b/rust/hg-core/src/dagops.rs Mon Feb 04 19:46:57 2019 +0100 @@ -46,7 +46,9 @@ let mut heads: HashSet<Revision> = iter_revs.clone().cloned().collect(); heads.remove(&NULL_REVISION); for rev in iter_revs { - remove_parents(graph, *rev, &mut heads)?; + if *rev != NULL_REVISION { + remove_parents(graph, *rev, &mut heads)?; + } } Ok(heads) } @@ -71,7 +73,9 @@ // mutating let as_vec: Vec<Revision> = revs.iter().cloned().collect(); for rev in as_vec { - remove_parents(graph, rev, revs)?; + if rev != NULL_REVISION { + remove_parents(graph, rev, revs)?; + } } Ok(()) }