Skip to content

Commit

Permalink
Avoid ref when using format! in compiler
Browse files Browse the repository at this point in the history
Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing).  Inlining format args prevents accidental `&` misuse.
  • Loading branch information
nyurik committed Jul 19, 2024
1 parent 25dce8f commit c1c13bd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
let nop_inst = fx.bcx.ins().nop();
fx.add_comment(
nop_inst,
format!("virtual call; self arg pass mode: {:?}", &fn_abi.args[0]),
format!("virtual call; self arg pass mode: {:?}", fn_abi.args[0]),
);
}

Expand Down

0 comments on commit c1c13bd

Please sign in to comment.