Skip to content

Commit

Permalink
Clippy + fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
maximopalopoli committed Nov 15, 2024
1 parent a9a83b1 commit eefdd07
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions crates/vm/levm/src/opcode_handlers/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,24 @@ impl VM {
.checked_add(1)
.ok_or(VMError::InvalidOpcode)?;

let mut readed_n_bytes: Vec<u8> = current_call_frame.bytecode[current_call_frame.pc..]
let mut readed_n_bytes: Vec<u8> = current_call_frame
.bytecode
.get(current_call_frame.pc()..)
.ok_or(VMError::InvalidBytecode)?
.iter()
.take(n_bytes)
.cloned()
.collect();

// If I have fewer bytes to read than I need, I add as many leading 0s as necessary
if readed_n_bytes.len() < n_bytes {
let padding = vec![0; n_bytes - readed_n_bytes.len()];
let gap_to_fill =
n_bytes
.checked_sub(readed_n_bytes.len())
.ok_or(VMError::Internal(
InternalError::ArithmeticOperationUnderflow,
))?;
let padding = vec![0; gap_to_fill];
readed_n_bytes.splice(0..0, padding);
}

Expand Down

0 comments on commit eefdd07

Please sign in to comment.