Skip to content
Snippets Groups Projects
Commit 78a758bf authored by Ashley's avatar Ashley Committed by Bastian Köcher
Browse files

Rewrite `elected_edges.sort_unstable_by` in phragmen (#4195)

* Rewrite phragmen elected_edges.sort_unstable_by

* map -> and_then
parent 04571d95
No related merge requests found
......@@ -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;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment