From 58c1c7a10d8cc1a4a35904258151d5e34c983b64 Mon Sep 17 00:00:00 2001 From: Marcio Diaz Date: Wed, 11 Dec 2019 13:15:27 +0100 Subject: [PATCH] Improve is_member and is_runner. (#4356) --- substrate/frame/elections-phragmen/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/substrate/frame/elections-phragmen/src/lib.rs b/substrate/frame/elections-phragmen/src/lib.rs index 0b8cdba22f..0fa0515751 100644 --- a/substrate/frame/elections-phragmen/src/lib.rs +++ b/substrate/frame/elections-phragmen/src/lib.rs @@ -492,14 +492,14 @@ impl Module { /// /// Limited number of members. Binary search. Constant time factor. O(1) fn is_member(who: &T::AccountId) -> bool { - Self::members_ids().binary_search(who).is_ok() + Self::members().binary_search_by(|(a, _b)| a.cmp(who)).is_ok() } /// Check if `who` is currently an active runner. /// /// Limited number of runners-up. Binary search. Constant time factor. O(1) fn is_runner(who: &T::AccountId) -> bool { - Self::runners_up_ids().binary_search(who).is_ok() + Self::runners_up().binary_search_by(|(a, _b)| a.cmp(who)).is_ok() } /// Returns number of desired members.