diff options
| -rw-r--r-- | src/vm.rs | 23 |
1 files changed, 5 insertions, 18 deletions
@@ -120,11 +120,7 @@ impl VM { fn push(&mut self, value: Value) { unsafe { - *unwrap_unchecked_o( - self.stack - .offset(unwrap_unchecked_r(self.stack_len.try_into())) - .as_mut() - ) = value; + *self.stack.offset(self.stack_len as isize) = value; } self.stack_len += 1; } @@ -134,11 +130,7 @@ impl VM { // &self.stack[slot] // unsafe { self.stack.get_unchecked(slot) } unsafe { - unwrap_unchecked_o( - self.stack - .offset(unwrap_unchecked_r(slot.try_into())) - .as_ref() - ) + &*self.stack.offset(slot as isize) } } @@ -147,11 +139,7 @@ impl VM { // &mut self.stack[slot] // unsafe { self.stack.get_unchecked_mut(slot) } unsafe { - unwrap_unchecked_o( - self.stack - .offset(unwrap_unchecked_r(slot.try_into())) - .as_mut() - ) + &mut *self.stack.offset(slot as isize) } } @@ -161,9 +149,8 @@ impl VM { // self.stack.pop().unwrap_or_else(|| unsafe { std::hint::unreachable_unchecked() }) self.stack_len -= 1; unsafe { - ptr::replace( - self.stack.offset(unwrap_unchecked_r(self.stack_len.try_into())), - Value::Nil) + ptr::replace(self.stack.offset(self.stack_len as isize), + Value::Nil) } } |
