Skip to content

Commit

Permalink
Clean up unnecessary loop
Browse files Browse the repository at this point in the history
  • Loading branch information
udoprog committed Jul 30, 2023
1 parent 8366b09 commit 0808cc2
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions crates/rune/src/runtime/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1250,8 +1250,7 @@ impl Vm {
});
}

let value = vm_try!(self.stack.pop());
vm_try!(<()>::from_value(value));
vm_try!(<()>::from_value(vm_try!(self.stack.pop())));
VmResult::Ok(())
}
}
Expand Down Expand Up @@ -1444,8 +1443,7 @@ impl Vm {

#[cfg_attr(feature = "bench", inline(never))]
fn op_await(&mut self) -> VmResult<Shared<Future>> {
let value = vm_try!(self.stack.pop());
value.into_future()
vm_try!(self.stack.pop()).into_future()
}

#[cfg_attr(feature = "bench", inline(never))]
Expand Down Expand Up @@ -1945,9 +1943,7 @@ impl Vm {
let target = vm_try!(self.stack.pop());
let value = vm_try!(self.stack.pop());

// This is a useful pattern.
#[allow(clippy::never_loop)]
loop {
'out: {
// NB: local storage for string.
let local_field;

Expand All @@ -1957,7 +1953,7 @@ impl Vm {
local_field.as_str()
}
Value::StaticString(string) => string.as_ref(),
_ => break,
_ => break 'out,
};

match &target {
Expand Down Expand Up @@ -1994,9 +1990,7 @@ impl Vm {
target: variant.type_info(),
});
}
_ => {
break;
}
_ => {}
}
}

Expand All @@ -2010,8 +2004,6 @@ impl Vm {
});
}

// Calling index set should not produce a value on the stack, but all
// handler functions to produce a value. So pop it here.
vm_try!(<()>::from_value(vm_try!(self.stack.pop())));
VmResult::Ok(())
}
Expand Down Expand Up @@ -3048,12 +3040,10 @@ impl Vm {
}
Inst::Await => {
let future = vm_try!(self.op_await());
// NB: the future itself will advance the virtual machine.
return VmResult::Ok(VmHalt::Awaited(Awaited::Future(future)));
}
Inst::Select { len } => {
if let Some(select) = vm_try!(self.op_select(len)) {
// NB: the future itself will advance the virtual machine.
return VmResult::Ok(VmHalt::Awaited(Awaited::Select(select)));
}
}
Expand Down

0 comments on commit 0808cc2

Please sign in to comment.