clippy: add from_iter_instead_of_collect warn (#11666)

This commit is contained in:
Thomas Coratger
2024-10-11 19:56:33 +02:00
committed by GitHub
parent d8b7f6014f
commit bca11aa2dd
12 changed files with 85 additions and 80 deletions

View File

@ -2914,10 +2914,10 @@ impl<TX: DbTxMut + DbTx, Spec: Send + Sync> HashingWriter for DatabaseProvider<T
map
});
let hashed_storage_keys =
HashMap::from_iter(hashed_storages.iter().map(|(hashed_address, entries)| {
(*hashed_address, BTreeSet::from_iter(entries.keys().copied()))
}));
let hashed_storage_keys = hashed_storages
.iter()
.map(|(hashed_address, entries)| (*hashed_address, entries.keys().copied().collect()))
.collect();
let mut hashed_storage_cursor = self.tx.cursor_dup_write::<tables::HashedStorages>()?;
// Hash the address and key and apply them to HashedStorage (if Storage is None

View File

@ -324,11 +324,10 @@ fn block3(
)
.state_storage(
address,
HashMap::from_iter(
slot_range
.clone()
.map(|slot| (U256::from(slot), (U256::ZERO, U256::from(slot)))),
),
slot_range
.clone()
.map(|slot| (U256::from(slot), (U256::ZERO, U256::from(slot))))
.collect(),
)
.revert_account_info(number, address, Some(None))
.revert_storage(number, address, Vec::new());
@ -393,20 +392,18 @@ fn block4(
)
.state_storage(
address,
HashMap::from_iter(
slot_range.clone().map(|slot| {
(U256::from(slot), (U256::from(slot), U256::from(slot * 2)))
}),
),
slot_range
.clone()
.map(|slot| (U256::from(slot), (U256::from(slot), U256::from(slot * 2))))
.collect(),
)
} else {
bundle_state_builder.state_address(address).state_storage(
address,
HashMap::from_iter(
slot_range
.clone()
.map(|slot| (U256::from(slot), (U256::from(slot), U256::ZERO))),
),
slot_range
.clone()
.map(|slot| (U256::from(slot), (U256::from(slot), U256::ZERO)))
.collect(),
)
};
// record previous account info
@ -423,7 +420,7 @@ fn block4(
.revert_storage(
number,
address,
Vec::from_iter(slot_range.clone().map(|slot| (U256::from(slot), U256::from(slot)))),
slot_range.clone().map(|slot| (U256::from(slot), U256::from(slot))).collect(),
);
}
let execution_outcome = ExecutionOutcome::new(
@ -485,12 +482,11 @@ fn block5(
)
.state_storage(
address,
HashMap::from_iter(
slot_range
.clone()
.take(50)
.map(|slot| (U256::from(slot), (U256::from(slot), U256::from(slot * 4)))),
),
slot_range
.clone()
.take(50)
.map(|slot| (U256::from(slot), (U256::from(slot), U256::from(slot * 4))))
.collect(),
);
bundle_state_builder = if idx % 2 == 0 {
bundle_state_builder
@ -506,9 +502,10 @@ fn block5(
.revert_storage(
number,
address,
Vec::from_iter(
slot_range.clone().map(|slot| (U256::from(slot), U256::from(slot * 2))),
),
slot_range
.clone()
.map(|slot| (U256::from(slot), U256::from(slot * 2)))
.collect(),
)
} else {
bundle_state_builder.revert_address(number, address)