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