Fix clippy's performance lints (#1286)

* Fix clippy perf lints

* Cargo fmt

* Add  and  to lint rule in Makefile

* Fix some leftover clippy lints
This commit is contained in:
pscott
2020-06-25 16:04:08 +02:00
committed by GitHub
parent b3c01bf09d
commit 02174e21d8
26 changed files with 82 additions and 84 deletions

View File

@@ -237,7 +237,7 @@ impl<T: BeaconChainTypes> AttestationService<T> {
&mut self,
_message_id: &MessageId,
peer_id: &PeerId,
subnet: &SubnetId,
subnet: SubnetId,
attestation: &Attestation<T::EthSpec>,
) -> bool {
// verify the attestation is on the correct subnet
@@ -249,7 +249,7 @@ impl<T: BeaconChainTypes> AttestationService<T> {
}
};
if expected_subnet != *subnet {
if expected_subnet != subnet {
warn!(self.log, "Received an attestation on the wrong subnet"; "subnet_received" => format!("{:?}", subnet), "subnet_expected" => format!("{:?}",expected_subnet), "peer_id" => format!("{}", peer_id));
return false;
}

View File

@@ -218,11 +218,9 @@ impl<T: BeaconChainTypes> Router<T> {
match gossip_message {
// Attestations should never reach the router.
PubsubMessage::AggregateAndProofAttestation(aggregate_and_proof) => {
if let Some(gossip_verified) =
self.processor.verify_aggregated_attestation_for_gossip(
peer_id.clone(),
*aggregate_and_proof.clone(),
)
if let Some(gossip_verified) = self
.processor
.verify_aggregated_attestation_for_gossip(peer_id.clone(), *aggregate_and_proof)
{
self.propagate_message(id, peer_id.clone());
self.processor

View File

@@ -300,7 +300,7 @@ fn spawn_service<T: BeaconChainTypes>(
if service.attestation_service.should_process_attestation(
&id,
&source,
subnet,
*subnet,
attestation,
) {
let _ = service

View File

@@ -529,7 +529,7 @@ impl<T: BeaconChainTypes> SyncManager<T> {
// otherwise, this is a range sync issue, notify the range sync
self.range_sync
.inject_error(&mut self.network, peer_id.clone(), request_id);
.inject_error(&mut self.network, peer_id, request_id);
}
fn peer_disconnect(&mut self, peer_id: &PeerId) {
@@ -667,7 +667,7 @@ impl<T: BeaconChainTypes> SyncManager<T> {
"last_peer" => format!("{:?}", parent_request.last_submitted_peer),
);
self.network
.downvote_peer(parent_request.last_submitted_peer.clone());
.downvote_peer(parent_request.last_submitted_peer);
return;
}
Err(e) => {
@@ -677,7 +677,7 @@ impl<T: BeaconChainTypes> SyncManager<T> {
"last_peer" => format!("{:?}", parent_request.last_submitted_peer),
);
self.network
.downvote_peer(parent_request.last_submitted_peer.clone());
.downvote_peer(parent_request.last_submitted_peer);
return;
}
}