From 6db59d1f37bea6e4ac8b711285362a3e73715e5a Mon Sep 17 00:00:00 2001 From: bear Date: Fri, 3 Nov 2023 13:27:26 +0800 Subject: [PATCH] Fix clippy --- frame/evm/src/runner/stack.rs | 41 +++++++++++++++++------------------ 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index 387ec78163..7b645f6bf7 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -982,18 +982,18 @@ where .try_record_proof_size_or_fail(ACCOUNT_CODES_METADATA_PROOF_SIZE)?; if let Some(meta) = >::get(address) { weight_info.try_record_proof_size_or_fail(meta.size)?; - } else { - if let Some(remaining_proof_size) = weight_info.remaining_proof_size() { - let pre_size = remaining_proof_size.min(size_limit); - weight_info.try_record_proof_size_or_fail(pre_size)?; - - let actual_size = Pallet::::account_code_metadata(address).size; - if actual_size > pre_size { - return Err(ExitError::OutOfGas); - } - // Refund unused proof size - weight_info.refund_proof_size(pre_size.saturating_sub(actual_size)); + } else if let Some(remaining_proof_size) = + weight_info.remaining_proof_size() + { + let pre_size = remaining_proof_size.min(size_limit); + weight_info.try_record_proof_size_or_fail(pre_size)?; + + let actual_size = Pallet::::account_code_metadata(address).size; + if actual_size > pre_size { + return Err(ExitError::OutOfGas); } + // Refund unused proof size + weight_info.refund_proof_size(pre_size.saturating_sub(actual_size)); } recorded.account_codes.push(address); } @@ -1062,19 +1062,18 @@ where if let Some(meta) = >::get(address) { weight_info.try_record_proof_size_or_fail(meta.size)?; - } else { - if let Some(remaining_proof_size) = weight_info.remaining_proof_size() { - let pre_size = remaining_proof_size.min(size_limit); - weight_info.try_record_proof_size_or_fail(pre_size)?; + } else if let Some(remaining_proof_size) = weight_info.remaining_proof_size() { + let pre_size = remaining_proof_size.min(size_limit); + weight_info.try_record_proof_size_or_fail(pre_size)?; - let actual_size = Pallet::::account_code_metadata(address).size; - if actual_size > pre_size { - return Err(ExitError::OutOfGas); - } - // Refund unused proof size - weight_info.refund_proof_size(pre_size.saturating_sub(actual_size)); + let actual_size = Pallet::::account_code_metadata(address).size; + if actual_size > pre_size { + return Err(ExitError::OutOfGas); } + // Refund unused proof size + weight_info.refund_proof_size(pre_size.saturating_sub(actual_size)); } + Ok(()) };