not really faster. Maybe more clear.

main
_ 2023-10-02 20:28:36 -05:00
parent 7878efc235
commit 55ea0c233e
1 changed files with 6 additions and 11 deletions

View File

@ -541,16 +541,11 @@ impl State {
Instruction::AddI (a, b, s_c) => {
let v_b = self.reg (b);
let x = if let Some (v_b) = v_b.as_int ()
{
Value::from (v_b + s_c as i64)
}
else {
let v_b = v_b.as_float ().unwrap_or_else (|| panic! ("{v_b}"));
Value::from (v_b + f64::from (s_c))
*self.reg_mut (a) = match v_b {
Value::Integer (v_b) => Value::from (v_b + s_c as i64),
Value::Float (v_b) => Value::from (v_b + s_c as f64),
x => panic! ("{x}"),
};
*self.reg_mut (a) = x;
},
Instruction::Call (a, b, c) => {
if self.op_call (a, b, c) {
@ -678,11 +673,11 @@ impl State {
Instruction::GetUpVal (a, b) => {
let this_func = self.stack_top.register_offset - 1;
let closure = match &self.registers [this_func] {
Value::BogusClosure (rc) => rc.clone (),
Value::BogusClosure (rc) => rc,
_ => panic! ("Can't do GetUpVal outside a closure"),
};
let b = usize::try_from (b).unwrap ();
let b = usize::try_from (b).unwrap ();
let upvalue = match closure.borrow ().upvalues.get (b) {
Some (x) => x.clone (),