From 5a27e34e4c38486050cf5ea5d2ed85e7e53efa2f Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Mon, 10 Sep 2018 23:47:55 -0400 Subject: [PATCH] Pass label by value to VirtualMachine.jump() Per [0], this is more efficient for usize. [0] https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#trivially_copy_pass_by_ref --- vm/src/vm.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/vm/src/vm.rs b/vm/src/vm.rs index d01309a18..1286f2d03 100644 --- a/vm/src/vm.rs +++ b/vm/src/vm.rs @@ -193,7 +193,7 @@ impl VirtualMachine { match block { Some(Block::TryExcept { handler }) => { self.push_value(exc); - self.jump(&handler); + self.jump(handler); return None; } Some(_) => {} @@ -866,7 +866,7 @@ impl VirtualMachine { } else { panic!("Wrong block type") }; - self.jump(&end_label); + self.jump(end_label); None } else { Some(Err(next_error)) @@ -939,7 +939,7 @@ impl VirtualMachine { } } bytecode::Instruction::Jump { target } => { - self.jump(target); + self.jump(*target); None } bytecode::Instruction::JumpIf { target } => { @@ -947,7 +947,7 @@ impl VirtualMachine { match objbool::boolval(self, obj) { Ok(value) => { if value { - self.jump(target); + self.jump(*target); } None } @@ -960,7 +960,7 @@ impl VirtualMachine { match objbool::boolval(self, obj) { Ok(value) => { if !value { - self.jump(target); + self.jump(*target); } None } @@ -994,7 +994,7 @@ impl VirtualMachine { bytecode::Instruction::Break => { let block = self.unwind_loop(); if let Block::Loop { start: _, end } = block { - self.jump(&end); + self.jump(end); } None } @@ -1005,7 +1005,7 @@ impl VirtualMachine { bytecode::Instruction::Continue => { let block = self.unwind_loop(); if let Block::Loop { start, end: _ } = block { - self.jump(&start); + self.jump(start); } else { assert!(false); } @@ -1065,9 +1065,9 @@ impl VirtualMachine { } } - fn jump(&mut self, label: &bytecode::Label) { + fn jump(&mut self, label: bytecode::Label) { let current_frame = self.current_frame_mut(); - let target_pc = current_frame.code.label_map[label]; + let target_pc = current_frame.code.label_map[&label]; trace!( "program counter from {:?} to {:?}", current_frame.lasti,