Removes redundant mut
in util
This commit is contained in:
parent
74876fd410
commit
96b4467f86
@ -254,12 +254,12 @@ impl KeyValueDB for InMemory {
|
|||||||
for op in ops {
|
for op in ops {
|
||||||
match op {
|
match op {
|
||||||
DBOp::Insert { col, key, value } => {
|
DBOp::Insert { col, key, value } => {
|
||||||
if let Some(mut col) = columns.get_mut(&col) {
|
if let Some(col) = columns.get_mut(&col) {
|
||||||
col.insert(key.into_vec(), value);
|
col.insert(key.into_vec(), value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DBOp::InsertCompressed { col, key, value } => {
|
DBOp::InsertCompressed { col, key, value } => {
|
||||||
if let Some(mut col) = columns.get_mut(&col) {
|
if let Some(col) = columns.get_mut(&col) {
|
||||||
let compressed = UntrustedRlp::new(&value).compress(RlpType::Blocks);
|
let compressed = UntrustedRlp::new(&value).compress(RlpType::Blocks);
|
||||||
let mut value = DBValue::new();
|
let mut value = DBValue::new();
|
||||||
value.append_slice(&compressed);
|
value.append_slice(&compressed);
|
||||||
@ -267,7 +267,7 @@ impl KeyValueDB for InMemory {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
DBOp::Delete { col, key } => {
|
DBOp::Delete { col, key } => {
|
||||||
if let Some(mut col) = columns.get_mut(&col) {
|
if let Some(col) = columns.get_mut(&col) {
|
||||||
col.remove(&*key);
|
col.remove(&*key);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -156,7 +156,7 @@ impl Discovery {
|
|||||||
trace!(target: "discovery", "Inserting {:?}", &e);
|
trace!(target: "discovery", "Inserting {:?}", &e);
|
||||||
let id_hash = keccak(e.id);
|
let id_hash = keccak(e.id);
|
||||||
let ping = {
|
let ping = {
|
||||||
let mut bucket = &mut self.node_buckets[Discovery::distance(&self.id_hash, &id_hash) as usize];
|
let bucket = &mut self.node_buckets[Discovery::distance(&self.id_hash, &id_hash) as usize];
|
||||||
let updated = if let Some(node) = bucket.nodes.iter_mut().find(|n| n.address.id == e.id) {
|
let updated = if let Some(node) = bucket.nodes.iter_mut().find(|n| n.address.id == e.id) {
|
||||||
node.address = e.clone();
|
node.address = e.clone();
|
||||||
node.timeout = None;
|
node.timeout = None;
|
||||||
@ -169,7 +169,7 @@ impl Discovery {
|
|||||||
|
|
||||||
if bucket.nodes.len() > BUCKET_SIZE {
|
if bucket.nodes.len() > BUCKET_SIZE {
|
||||||
//ping least active node
|
//ping least active node
|
||||||
let mut last = bucket.nodes.back_mut().expect("Last item is always present when len() > 0");
|
let last = bucket.nodes.back_mut().expect("Last item is always present when len() > 0");
|
||||||
last.timeout = Some(time::precise_time_ns());
|
last.timeout = Some(time::precise_time_ns());
|
||||||
Some(last.address.endpoint.clone())
|
Some(last.address.endpoint.clone())
|
||||||
} else { None }
|
} else { None }
|
||||||
@ -180,7 +180,7 @@ impl Discovery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn clear_ping(&mut self, id: &NodeId) {
|
fn clear_ping(&mut self, id: &NodeId) {
|
||||||
let mut bucket = &mut self.node_buckets[Discovery::distance(&self.id_hash, &keccak(id)) as usize];
|
let bucket = &mut self.node_buckets[Discovery::distance(&self.id_hash, &keccak(id)) as usize];
|
||||||
if let Some(node) = bucket.nodes.iter_mut().find(|n| &n.address.id == id) {
|
if let Some(node) = bucket.nodes.iter_mut().find(|n| &n.address.id == id) {
|
||||||
node.timeout = None;
|
node.timeout = None;
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ impl NodeTable {
|
|||||||
/// Apply table changes coming from discovery
|
/// Apply table changes coming from discovery
|
||||||
pub fn update(&mut self, mut update: TableUpdates, reserved: &HashSet<NodeId>) {
|
pub fn update(&mut self, mut update: TableUpdates, reserved: &HashSet<NodeId>) {
|
||||||
for (_, node) in update.added.drain() {
|
for (_, node) in update.added.drain() {
|
||||||
let mut entry = self.nodes.entry(node.id.clone()).or_insert_with(|| Node::new(node.id.clone(), node.endpoint.clone()));
|
let entry = self.nodes.entry(node.id.clone()).or_insert_with(|| Node::new(node.id.clone(), node.endpoint.clone()));
|
||||||
entry.endpoint = node.endpoint;
|
entry.endpoint = node.endpoint;
|
||||||
}
|
}
|
||||||
for r in update.removed {
|
for r in update.removed {
|
||||||
|
@ -91,7 +91,7 @@ impl<Row, Col, Val> Table<Row, Col, Val>
|
|||||||
if let None = row_map {
|
if let None = row_map {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let mut row_map = row_map.unwrap();
|
let row_map = row_map.unwrap();
|
||||||
let val = row_map.remove(col);
|
let val = row_map.remove(col);
|
||||||
(val, row_map.is_empty())
|
(val, row_map.is_empty())
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user