Skip to content

Commit f6e99d1

Browse files
authored
Merge pull request RustPython#574 from RustPython/fetch_ins
fetch_instruction can just return a reference.
2 parents b0ee194 + 786eb2c commit f6e99d1

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)