Skip to content

Commit

Permalink
Fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
sambley committed Apr 14, 2019
1 parent c2abdc2 commit 1a9aaa6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
5 changes: 3 additions & 2 deletions core/src/bank_forks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ impl BankForks {
}

/// Create a map of bank slot id to the set of all of its descendants
#[allow(clippy::or_fun_call)]
pub fn descendants(&self) -> HashMap<u64, HashSet<u64>> {
let mut descendants = HashMap::new();
for bank in self.banks.values() {
Expand Down Expand Up @@ -214,8 +215,8 @@ mod tests {
let bank = Bank::new_from_parent(&bank0, &Pubkey::default(), 2);
bank_forks.insert(bank);
let descendants = bank_forks.descendants();
let children: Vec<u64> = descendants[&0].iter().cloned().collect();
assert_eq!(children, vec![2, 1]);
let children: HashSet<u64> = [1u64, 2u64].to_vec().into_iter().collect();
assert_eq!(children, *descendants.get(&0).unwrap());
assert!(descendants[&1].is_empty());
assert!(descendants[&2].is_empty());
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/replay_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ impl ReplayStage {
let bank_slot = bank.slot();
let bank_progress = &mut progress
.entry(bank_slot)
.or_insert(ForkProgress::new(bank.last_blockhash()));
.or_insert_with(|| ForkProgress::new(bank.last_blockhash()));
blocktree.get_slot_entries_with_blob_count(bank_slot, bank_progress.num_blobs as u64, None)
}

Expand All @@ -501,7 +501,7 @@ impl ReplayStage {
) -> result::Result<()> {
let bank_progress = &mut progress
.entry(bank.slot())
.or_insert(ForkProgress::new(bank.last_blockhash()));
.or_insert_with(|| ForkProgress::new(bank.last_blockhash()));
let result = Self::verify_and_process_entries(&bank, &entries, &bank_progress.last_entry);
bank_progress.num_blobs += num;
if let Some(last_entry) = entries.last() {
Expand Down
9 changes: 4 additions & 5 deletions runtime/src/append_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ macro_rules! align_up {
}

#[derive(Debug)]
#[allow(clippy::mutex_atomic)]
pub struct AppendVec {
path: PathBuf,
map: MmapMut,
Expand Down Expand Up @@ -225,11 +226,8 @@ impl Serialize for AppendVec {
let mut buf = vec![0u8; len as usize];
let mut wr = Cursor::new(&mut buf[..]);
serialize_into(&mut wr, &self.path).map_err(Error::custom)?;
serialize_into(
&mut wr,
&(self.current_len.load(Ordering::Relaxed) as u64),
)
.map_err(Error::custom)?;
serialize_into(&mut wr, &(self.current_len.load(Ordering::Relaxed) as u64))
.map_err(Error::custom)?;
serialize_into(&mut wr, &self.file_size).map_err(Error::custom)?;
let len = wr.position() as usize;
serializer.serialize_bytes(&wr.into_inner()[..len])
Expand All @@ -245,6 +243,7 @@ impl<'a> serde::de::Visitor<'a> for AppendVecVisitor {
formatter.write_str("Expecting AppendVec")
}

#[allow(clippy::mutex_atomic)]
fn visit_bytes<E>(self, data: &[u8]) -> std::result::Result<Self::Value, E>
where
E: serde::de::Error,
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/status_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl<T: Clone> StatusCache<T> {
.entry(*transaction_blockhash)
.or_insert((fork, HashMap::new()));
sig_map.0 = std::cmp::max(fork, sig_map.0);
let sig_forks = sig_map.1.entry(*sig).or_insert(vec![]);
let sig_forks = sig_map.1.entry(*sig).or_insert_with(|| vec![]);
sig_forks.push((fork, res));
}

Expand Down

0 comments on commit 1a9aaa6

Please sign in to comment.