From 786eb2cbfbae0899e632ec9df9103a75ce0bf05f Mon Sep 17 00:00:00 2001 From: Adam Kelly Date: Thu, 28 Feb 2019 08:33:43 +0000 Subject: [PATCH] fetch_instruction can just return a reference. --- vm/src/frame.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/vm/src/frame.rs b/vm/src/frame.rs index b6253b6c6a..9eeb584bd3 100644 --- a/vm/src/frame.rs +++ b/vm/src/frame.rs @@ -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 }