Rewrite elected_edges.sort_unstable_by in phragmen (#4195)

* Rewrite phragmen elected_edges.sort_unstable_by

* map -> and_then
This commit is contained in:
Ashley
2019-11-25 11:43:26 +01:00
committed by Bastian Köcher
parent 04571d958b
commit 78a758bfba
+3 -10
View File
@@ -274,17 +274,10 @@ pub(crate) fn do_equalize_float<A>(
e.1 = 0.0;
});
// todo: rewrite.
elected_edges.sort_unstable_by(|x, y|
if let Some(x) = support_map.get(&x.0) {
if let Some(y) = support_map.get(&y.0) {
x.total.partial_cmp(&y.total).unwrap_or(rstd::cmp::Ordering::Equal)
} else {
rstd::cmp::Ordering::Equal
}
} else {
rstd::cmp::Ordering::Equal
}
support_map.get(&x.0)
.and_then(|x| support_map.get(&y.0).and_then(|y| x.total.partial_cmp(&y.total)))
.unwrap_or(rstd::cmp::Ordering::Equal)
);
let mut cumulative_stake = 0.0;