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

@@ -80,10 +80,9 @@ impl ForkChoiceTestDefinition {
finalized_epoch,
&justified_state_balances,
)
.expect(&format!(
"find_head op at index {} returned error",
op_index
));
.unwrap_or_else(|_| {
panic!("find_head op at index {} returned error", op_index)
});
assert_eq!(
head, expected_head,
@@ -129,10 +128,9 @@ impl ForkChoiceTestDefinition {
justified_epoch,
finalized_epoch,
)
.expect(&format!(
"process_block op at index {} returned error",
op_index
));
.unwrap_or_else(|_| {
panic!("process_block op at index {} returned error", op_index)
});
check_bytes_round_trip(&fork_choice);
}
Operation::ProcessAttestation {
@@ -142,10 +140,12 @@ impl ForkChoiceTestDefinition {
} => {
fork_choice
.process_attestation(validator_index, block_root, target_epoch)
.expect(&format!(
"process_attestation op at index {} returned error",
op_index
));
.unwrap_or_else(|_| {
panic!(
"process_attestation op at index {} returned error",
op_index
)
});
check_bytes_round_trip(&fork_choice);
}
Operation::Prune {

View File

@@ -91,7 +91,7 @@ pub fn get_ffg_case_01_test_definition() -> ForkChoiceTestDefinition {
justified_epoch: Epoch::new(2),
justified_root: get_hash(3),
finalized_epoch: Epoch::new(1),
justified_state_balances: balances.clone(),
justified_state_balances: balances,
expected_head: get_hash(3),
});
@@ -421,7 +421,7 @@ pub fn get_ffg_case_02_test_definition() -> ForkChoiceTestDefinition {
justified_epoch: Epoch::new(3),
justified_root: get_hash(2),
finalized_epoch: Epoch::new(0),
justified_state_balances: balances.clone(),
justified_state_balances: balances,
});
// END OF TESTS

View File

@@ -212,7 +212,7 @@ pub fn get_no_votes_test_definition() -> ForkChoiceTestDefinition {
justified_epoch: Epoch::new(2),
justified_root: get_hash(5),
finalized_epoch: Epoch::new(1),
justified_state_balances: balances.clone(),
justified_state_balances: balances,
expected_head: get_hash(6),
},
];

View File

@@ -673,7 +673,7 @@ pub fn get_votes_test_definition() -> ForkChoiceTestDefinition {
justified_epoch: Epoch::new(2),
justified_root: get_hash(5),
finalized_epoch: Epoch::new(2),
justified_state_balances: balances.clone(),
justified_state_balances: balances,
expected_head: get_hash(11),
});