Skip to content

Commit 786eb2c

Browse files
committed
fetch_instruction can just return a reference.
1 parent b0ee194 commit 786eb2c

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

vm/src/frame.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,8 @@ impl Frame {
141141
value
142142
}
143143

144-
pub fn fetch_instruction(&self) -> bytecode::Instruction {
145-
// TODO: an immutable reference is enough, we should not
146-
// clone the instruction.
147-
let ins2 = self.code.instructions[*self.lasti.borrow()].clone();
144+
pub fn fetch_instruction(&self) -> &bytecode::Instruction {
145+
let ins2 = &self.code.instructions[*self.lasti.borrow()];
148146
*self.lasti.borrow_mut() += 1;
149147
ins2
150148
}

0 commit comments

Comments
 (0)