From e03203b14dd98c0f48e012d5fb5a2c02a09230ab Mon Sep 17 00:00:00 2001 From: Patrick LaFontaine <32135464+Pat-Lafon@users.noreply.github.com> Date: Tue, 7 May 2024 10:50:43 -0700 Subject: [PATCH 1/2] Unnecessary to_string --- brilirs/src/basic_block.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brilirs/src/basic_block.rs b/brilirs/src/basic_block.rs index 5f78df0a3..7294f58c6 100644 --- a/brilirs/src/basic_block.rs +++ b/brilirs/src/basic_block.rs @@ -42,7 +42,7 @@ impl BBProgram { .collect::, InterpError>>()?; let bb = Self { - index_of_main: func_map.get(&"main".to_string()).copied(), + index_of_main: func_map.get("main").copied(), func_index, }; if func_map.len() == num_funcs { From 0eb549d678756ba7c5ab5763f1cdd2949da826fb Mon Sep 17 00:00:00 2001 From: Patrick LaFontaine <32135464+Pat-Lafon@users.noreply.github.com> Date: Tue, 7 May 2024 11:02:26 -0700 Subject: [PATCH 2/2] Use clone_from --- bril-rs/rs2bril/src/lib.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/bril-rs/rs2bril/src/lib.rs b/bril-rs/rs2bril/src/lib.rs index 03f1d3c7c..7d13a9e04 100644 --- a/bril-rs/rs2bril/src/lib.rs +++ b/bril-rs/rs2bril/src/lib.rs @@ -62,7 +62,8 @@ impl State { } fn starting_new_function(&mut self, name: &String) { - self.ident_type_map = self.func_context_map.get(name).unwrap().0.clone(); + self.ident_type_map + .clone_from(&self.func_context_map.get(name).unwrap().0); } fn add_type_for_ident(&mut self, ident: String, ty: Type) { @@ -570,35 +571,35 @@ fn from_expr_to_bril(expr: Expr, state: &mut State) -> (Option, Vec { - place_expression = arg1.clone(); + place_expression.clone_from(&arg1); (ValueOps::Add, Type::Int) } (BinOp::AddAssign(_), Type::Float) => { - place_expression = arg1.clone(); + place_expression.clone_from(&arg1); (ValueOps::Fadd, Type::Float) } (BinOp::SubAssign(_), Type::Int) => { - place_expression = arg1.clone(); + place_expression.clone_from(&arg1); (ValueOps::Sub, Type::Int) } (BinOp::SubAssign(_), Type::Float) => { - place_expression = arg1.clone(); + place_expression.clone_from(&arg1); (ValueOps::Fsub, Type::Float) } (BinOp::MulAssign(_), Type::Int) => { - place_expression = arg1.clone(); + place_expression.clone_from(&arg1); (ValueOps::Mul, Type::Int) } (BinOp::MulAssign(_), Type::Float) => { - place_expression = arg1.clone(); + place_expression.clone_from(&arg1); (ValueOps::Fmul, Type::Float) } (BinOp::DivAssign(_), Type::Int) => { - place_expression = arg1.clone(); + place_expression.clone_from(&arg1); (ValueOps::Div, Type::Int) } (BinOp::DivAssign(_), Type::Float) => { - place_expression = arg1.clone(); + place_expression.clone_from(&arg1); (ValueOps::Fdiv, Type::Float) } (_, _) => unimplemented!("{op:?}"),