Double unwrap for program_base
in Cairo runner initialize_state
#1638
Labels
enhancement
New feature or request
program_base
in Cairo runner initialize_state
#1638
Issue Description
In the
initialize_state
function of theCairoRunner
structure, there is redundant code in my opinion, that can be improved for clarity and efficiency.At the beginning of the function, there is a conditional check (
if let Some(prog_base) = self.program_base
) to ensure thatself.program_base
is notNone
.cairo-vm/vm/src/vm/runners/cairo_runner.rs
Lines 414 to 431 in 4ea224a
However, a few lines later, the
unwrap
method is used again onself.program_base
to obtainbase
, and in case ofNone
, it setsbase
toRelocatable::from((0, 0))
.cairo-vm/vm/src/vm/runners/cairo_runner.rs
Lines 425 to 427 in 4ea224a
This redundant check and assignment can be eliminated because the
None
case will never happen inside theif
statement, making thebase
declaration unnecessary. Instead, we can directly use theprog_base
variable in the loop to mark memory segments as accessed.The text was updated successfully, but these errors were encountered: