fetch_instruction can just return a reference.

This commit is contained in:
Adam Kelly
2019-02-28 08:33:43 +00:00
parent b0ee1947c7
commit 786eb2cbfb

View File

@@ -141,10 +141,8 @@ impl Frame {
value
}
pub fn fetch_instruction(&self) -> bytecode::Instruction {
// TODO: an immutable reference is enough, we should not
// clone the instruction.
let ins2 = self.code.instructions[*self.lasti.borrow()].clone();
pub fn fetch_instruction(&self) -> &bytecode::Instruction {
let ins2 = &self.code.instructions[*self.lasti.borrow()];
*self.lasti.borrow_mut() += 1;
ins2
}