diff --git a/crates/database/src/states/bundle_state.rs b/crates/database/src/states/bundle_state.rs index 7b24298e04..f4b0a6cceb 100644 --- a/crates/database/src/states/bundle_state.rs +++ b/crates/database/src/states/bundle_state.rs @@ -307,7 +307,7 @@ impl BundleBuilder { reverts_size += account_revert.size_hint(); reverts_map .entry(block_number) - .or_insert(Vec::new()) + .or_insert_with(Vec::new) .push((address, account_revert)); } }); @@ -618,7 +618,7 @@ impl BundleState { // database so we can check if plain state was wiped or not. let mut account_storage_changed = Vec::with_capacity(account.storage.len()); - for (key, slot) in account.storage.iter().map(|(k, v)| (*k, *v)) { + for (&key, &slot) in account.storage.iter() { // If storage was destroyed that means that storage was wiped. // In that case we need to check if present storage value is different then ZERO. let destroyed_and_not_zero = was_destroyed && !slot.present_value.is_zero(); diff --git a/crates/database/src/states/state.rs b/crates/database/src/states/state.rs index 76ba828a6f..22f8263343 100644 --- a/crates/database/src/states/state.rs +++ b/crates/database/src/states/state.rs @@ -93,7 +93,8 @@ impl State { balances: impl IntoIterator, ) -> Result<(), DB::Error> { // Make transition and update cache state - let mut transitions = Vec::new(); + let balances = balances.into_iter(); + let mut transitions = Vec::with_capacity(balances.size_hint().0); for (address, balance) in balances { if balance == 0 { continue; diff --git a/crates/inspector/src/count_inspector.rs b/crates/inspector/src/count_inspector.rs index dd29efe15f..a80d09af62 100644 --- a/crates/inspector/src/count_inspector.rs +++ b/crates/inspector/src/count_inspector.rs @@ -47,7 +47,7 @@ impl CountInspector { /// Get the count for a specific opcode. pub fn get_count(&self, opcode: u8) -> u64 { - self.opcode_counts.get(&opcode).copied().unwrap_or(0) + self.opcode_counts.get(&opcode).copied().unwrap_or_default() } /// Get a reference to all opcode counts. diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index fd1f0b8c14..8fb8bceeb2 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -56,7 +56,7 @@ pub const SHORT_ADDRESS_CAP: usize = 300; #[inline] pub fn short_address(address: &Address) -> Option { if address.0[..18].iter().all(|b| *b == 0) { - let short_address = u16::from_be_bytes(address.0[18..].try_into().unwrap()) as usize; + let short_address = u16::from_be_bytes([address.0[18], address.0[19]]) as usize; if short_address < SHORT_ADDRESS_CAP { return Some(short_address); } diff --git a/crates/state/src/lib.rs b/crates/state/src/lib.rs index d10af7eac3..985af53a3d 100644 --- a/crates/state/src/lib.rs +++ b/crates/state/src/lib.rs @@ -52,46 +52,55 @@ impl Account { } /// Marks the account as self destructed. + #[inline] pub fn mark_selfdestruct(&mut self) { self.status |= AccountStatus::SelfDestructed; } /// Unmarks the account as self destructed. + #[inline] pub fn unmark_selfdestruct(&mut self) { self.status -= AccountStatus::SelfDestructed; } /// Is account marked for self destruct. + #[inline] pub fn is_selfdestructed(&self) -> bool { self.status.contains(AccountStatus::SelfDestructed) } /// Marks the account as touched + #[inline] pub fn mark_touch(&mut self) { self.status |= AccountStatus::Touched; } /// Unmarks the touch flag. + #[inline] pub fn unmark_touch(&mut self) { self.status -= AccountStatus::Touched; } /// If account status is marked as touched. + #[inline] pub fn is_touched(&self) -> bool { self.status.contains(AccountStatus::Touched) } /// Marks the account as newly created. + #[inline] pub fn mark_created(&mut self) { self.status |= AccountStatus::Created; } /// Unmarks the created flag. + #[inline] pub fn unmark_created(&mut self) { self.status -= AccountStatus::Created; } /// Marks the account as cold. + #[inline] pub fn mark_cold(&mut self) { self.status |= AccountStatus::Cold; } @@ -393,7 +402,7 @@ impl EvmStorageSlot { pub fn mark_warm_with_transaction_id(&mut self, transaction_id: usize) -> bool { let same_id = self.transaction_id == transaction_id; self.transaction_id = transaction_id; - let was_cold = core::mem::replace(&mut self.is_cold, false); + let was_cold = core::mem::take(&mut self.is_cold); if same_id { // only if transaction id is same we are returning was_cold.