This commit is contained in:
Anatoly Yakovenko 2018-04-17 12:48:06 -07:00
parent 249cead13e
commit 0b33615979
1 changed files with 2 additions and 8 deletions

View File

@ -23,11 +23,7 @@ impl Default for Node {
impl Node {
pub fn new(id: [u64; 8], weight: u64, addr: SocketAddr) -> Node {
Node {
id: id,
weight: weight,
addr: addr,
}
Node { id, weight, addr }
}
fn key(&self) -> i64 {
(self.weight as i64).checked_neg().unwrap()
@ -80,9 +76,7 @@ impl Subscribers {
Ok(())
}
pub fn insert(&mut self, ns: &[Node]) {
for n in ns.into_iter() {
self.data.push(n.clone());
}
self.data.extend_from_slice(ns);
self.data.sort_by_key(Node::key);
}
}