Pacify clippy

This commit is contained in:
Michael Vines
2022-01-21 16:01:22 -08:00
parent ce4f7601af
commit 6d5bbca630
37 changed files with 157 additions and 194 deletions

View File

@ -90,7 +90,7 @@ fn sync_bencher(bank: &Arc<Bank>, _bank_client: &BankClient, transactions: &[Tra
}
fn async_bencher(bank: &Arc<Bank>, bank_client: &BankClient, transactions: &[Transaction]) {
for transaction in transactions.to_owned() {
for transaction in transactions.iter().cloned() {
bank_client.async_send_transaction(transaction).unwrap();
}
for _ in 0..1_000_000_000_u64 {

View File

@ -4207,16 +4207,15 @@ impl AccountsDb {
.fetch_add(scan_storages_elasped.as_us(), Ordering::Relaxed);
let mut purge_accounts_index_elapsed = Measure::start("purge_accounts_index_elapsed");
let reclaims;
match scan_result {
let reclaims = match scan_result {
ScanStorageResult::Cached(_) => {
panic!("Should not see cached keys in this `else` branch, since we checked this slot did not exist in the cache above");
}
ScanStorageResult::Stored(stored_keys) => {
// Purge this slot from the accounts index
reclaims = self.purge_keys_exact(stored_keys.lock().unwrap().iter());
self.purge_keys_exact(stored_keys.lock().unwrap().iter())
}
}
};
purge_accounts_index_elapsed.stop();
purge_stats
.purge_accounts_index_elapsed
@ -5104,12 +5103,11 @@ impl AccountsDb {
.accounts_index
.account_maps
.iter()
.map(|map| {
.flat_map(|map| {
let mut keys = map.read().unwrap().keys();
keys.sort_unstable(); // hashmap is not ordered, but bins are relative to each other
keys
})
.flatten()
.collect();
collect.stop();

View File

@ -1154,7 +1154,7 @@ pub mod tests {
let sorted2 = chunk.clone();
let mut with_left_over = vec![left_over_1];
with_left_over.extend(sorted2[0..plus1 - 2].to_vec().into_iter().map(|i| i.hash));
with_left_over.extend(sorted2[0..plus1 - 2].iter().cloned().map(|i| i.hash));
let expected_hash2 = AccountsHash::compute_merkle_root(
with_left_over[0..target_fanout]
.iter()

View File

@ -12891,8 +12891,7 @@ pub(crate) mod tests {
assert!(cache.get(&key4).is_some());
let num_retained = [&key1, &key2, &key3]
.iter()
.map(|key| cache.get(key))
.flatten()
.filter_map(|key| cache.get(key))
.count();
assert_eq!(num_retained, 2);
@ -12903,8 +12902,7 @@ pub(crate) mod tests {
assert!(cache.get(&key3).is_some());
let num_retained = [&key1, &key2, &key4]
.iter()
.map(|key| cache.get(key))
.flatten()
.filter_map(|key| cache.get(key))
.count();
assert_eq!(num_retained, 2);
}
@ -12937,8 +12935,7 @@ pub(crate) mod tests {
assert!(cache.get(&key4).is_some());
let num_retained = [&key1, &key2, &key3]
.iter()
.map(|key| cache.get(key))
.flatten()
.filter_map(|key| cache.get(key))
.count();
assert_eq!(num_retained, 2);
@ -12948,8 +12945,7 @@ pub(crate) mod tests {
assert!(cache.get(&key3).is_some());
let num_retained = [&key2, &key4]
.iter()
.map(|key| cache.get(key))
.flatten()
.filter_map(|key| cache.get(key))
.count();
assert_eq!(num_retained, 1);

View File

@ -315,8 +315,7 @@ impl SyncClient for BankClient {
fn get_fee_for_message(&self, message: &Message) -> Result<u64> {
SanitizedMessage::try_from(message.clone())
.ok()
.map(|sanitized_message| self.bank.get_fee_for_message(&sanitized_message))
.flatten()
.and_then(|sanitized_message| self.bank.get_fee_for_message(&sanitized_message))
.ok_or_else(|| {
TransportError::IoError(io::Error::new(
io::ErrorKind::Other,

View File

@ -574,7 +574,7 @@ mod tests {
let bank = Bank::new_from_parent(&bank0, &Pubkey::default(), 2);
bank_forks.insert(bank);
let descendants = bank_forks.descendants();
let children: HashSet<u64> = [1u64, 2u64].to_vec().into_iter().collect();
let children: HashSet<u64> = [1u64, 2u64].iter().copied().collect();
assert_eq!(children, *descendants.get(&0).unwrap());
assert!(descendants[&1].is_empty());
assert!(descendants[&2].is_empty());

View File

@ -671,7 +671,7 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
where
R: RangeBounds<Pubkey>,
{
assert!(!(only_add_if_already_held && !start_holding));
assert!(!only_add_if_already_held || start_holding);
let start = match range.start_bound() {
Bound::Included(bound) | Bound::Excluded(bound) => *bound,
Bound::Unbounded => Pubkey::new(&[0; 32]),