Skip to content

Commit 8df8954

Browse files
Improve naming
1 parent 43b6b9d commit 8df8954

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

vm/src/vm/vm_core.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -564,18 +564,20 @@ impl VirtualMachine {
564564
hint_ranges: &mut HashMap<Relocatable, HintRange>,
565565
) -> Result<(), VirtualMachineError> {
566566
// Check if there is a hint range for the current pc
567-
if let Some((s, l)) = hint_ranges.get(&self.run_context.pc) {
567+
if let Some((start_hint_idx, n_hints)) = hint_ranges.get(&self.run_context.pc) {
568568
// Re-binding to avoid mutability problems
569-
let s = *s;
569+
let start_hint_idx = *start_hint_idx;
570570
// Execute each hint for the given range
571-
for idx in s..(s + l.get()) {
571+
for idx in start_hint_idx..(start_hint_idx + n_hints.get()) {
572572
let hint_extension = hint_processor
573573
.execute_hint_extensive(
574574
self,
575575
exec_scopes,
576576
hint_datas.get(idx).ok_or(VirtualMachineError::Unexpected)?,
577577
)
578-
.map_err(|err| VirtualMachineError::Hint(Box::new((idx - s, err))))?;
578+
.map_err(|err| {
579+
VirtualMachineError::Hint(Box::new((idx - start_hint_idx, err)))
580+
})?;
579581
// Update the hint_ranges & hint_datas with the hints added by the executed hint
580582
for (hint_pc, hints) in hint_extension {
581583
if let Ok(len) = NonZeroUsize::try_from(hints.len()) {
@@ -602,18 +604,20 @@ impl VirtualMachine {
602604
hint_ranges: &mut HashMap<Relocatable, HintRange>,
603605
) -> Result<(), VirtualMachineError> {
604606
// Check if there is a hint range for the current pc
605-
if let Some((s, l)) = hint_ranges.get(&self.run_context.pc) {
607+
if let Some((start_hint_idx, n_hints)) = hint_ranges.get(&self.run_context.pc) {
606608
// Re-binding to avoid mutability problems
607-
let s = *s;
609+
let start_hint_idx = *start_hint_idx;
608610
// Execute each hint for the given range
609-
for idx in s..(s + l.get()) {
611+
for idx in start_hint_idx..(start_hint_idx + n_hints.get()) {
610612
let hint_data = hint_datas
611613
.get(idx)
612614
.ok_or(VirtualMachineError::Unexpected)?
613615
.as_ref();
614616
let hint_extension = hint_processor
615617
.execute_hint_extensive(self, exec_scopes, hint_data)
616-
.map_err(|err| VirtualMachineError::Hint(Box::new((idx - s, err))))?;
618+
.map_err(|err| {
619+
VirtualMachineError::Hint(Box::new((idx - start_hint_idx, err)))
620+
})?;
617621
// Update the hint_ranges & hint_datas with the hints added by the executed hint
618622
for (hint_pc, hints) in hint_extension {
619623
if let Ok(len) = NonZeroUsize::try_from(hints.len()) {

0 commit comments

Comments
 (0)