diff options
| -rw-r--r-- | bytecode/src/heap.rs | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/bytecode/src/heap.rs b/bytecode/src/heap.rs index d32283e..d047d5a 100644 --- a/bytecode/src/heap.rs +++ b/bytecode/src/heap.rs @@ -7,11 +7,10 @@ fn rewrite_pointers( rewrites: &HashMap<Pointer, Pointer>, ) -> Result<(), String> { for val in stack.iter_mut() { - let p = match val.to_pointer() { - Ok(p) => p, - Err(_) => { - continue; - } + let p = if val.is_pointer() { + val.to_pointer().unwrap() + } else { + continue; }; let Pointer(u) = p; *val = Value::from_pointer( @@ -68,11 +67,10 @@ impl Heap { spare_heap_ptr: &mut usize, rewrites: &mut HashMap<Pointer, Pointer>, ) -> Result<(), String> { - let p = match val.to_pointer() { - Ok(p) => p, - Err(_) => { - return Ok(()); - } + let p = if val.is_pointer() { + val.to_pointer().unwrap() + } else { + return Ok(()); }; if rewrites.contains_key(&p) { // Already copied this one. @@ -128,11 +126,10 @@ impl Heap { for j in (i..i + self.alloc_size(p)?).step_by(8) { let q = Pointer(j); let val = self.peek(q)?; - let vp = match val.to_pointer() { - Ok(x) => x, - Err(_) => { - continue; - } + let vp = if val.is_pointer() { + val.to_pointer().unwrap() + } else { + continue; }; let Pointer(u) = vp; self.poke( @@ -144,6 +141,7 @@ impl Heap { q, )?; } + i += self.alloc_size(p)?; } self.last_reachable_cells = spare_heap_ptr; // Done?? |
