Skip to content

Commit

Permalink
Borrow self and add derive traits for OpCode (#231)
Browse files Browse the repository at this point in the history
* derive & borrow self
* clippy
  • Loading branch information
iFrostizz authored Oct 16, 2022
1 parent 30aa246 commit 9f513c1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions crates/revm/src/db/in_memory_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use sha3::{Digest, Keccak256};

pub type InMemoryDB = CacheDB<EmptyDB>;

impl InMemoryDB {
pub fn default() -> Self {
impl Default for InMemoryDB {
fn default() -> Self {
CacheDB::new(EmptyDB {})
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/evm_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> EVMImpl<'a, GSPEC, DB,

if crate::USE_GAS {
let zero_data_len = input.iter().filter(|v| **v == 0).count() as u64;
let non_zero_data_len = (input.len() as u64 - zero_data_len) as u64;
let non_zero_data_len = input.len() as u64 - zero_data_len;
let (accessed_accounts, accessed_slots) = {
if SPEC::enabled(BERLIN) {
let mut accessed_slots = 0_u64;
Expand Down
3 changes: 2 additions & 1 deletion crates/revm/src/instructions/opcode.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::gas;
use crate::SpecId;

#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub struct OpCode(u8);

pub const STOP: u8 = 0x00;
Expand Down Expand Up @@ -164,7 +165,7 @@ impl OpCode {
}

#[inline(always)]
pub const fn u8(self) -> u8 {
pub const fn u8(&self) -> u8 {
self.0
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/revm_precompiles/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub enum SpecId {

impl SpecId {
pub const fn enabled(self, spec_id: u8) -> bool {
spec_id as u8 >= self as u8
spec_id >= self as u8
}
}

Expand Down

0 comments on commit 9f513c1

Please sign in to comment.