Avoid ref when using format! for perf · patricklam/verify-rust-std@4d8afcd (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Commit 4d8afcd

Avoid ref when using format! for perf

Clean up a few minor refs in `format!` macro, as it has a tiny perf cost. A few more minor related cleanups.

File tree

5 files changed

lines changed

5 files changed

lines changed

Lines changed: 1 addition & 1 deletion

Original file line number Diff line number Diff line change
@@ -1026,7 +1026,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
1026 1026 /// assert_eq!(format!("{}", value), "a");
1027 1027 /// assert_eq!(format!("{:?}", value), "'a'");
1028 1028 ///
1029 -/// let wrapped = fmt::FormatterFn(|f
1029 +/// let wrapped = fmt::FormatterFn(|f
1030 1030 /// assert_eq!(format!("{}", wrapped), "'a'");
1031 1031 /// assert_eq!(format!("{:?}", wrapped), "'a'");
1032 1032 /// ```

Lines changed: 1 addition & 1 deletion

Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ fn test_join() {
56 56
57 57 let y = String::new();
58 58 let x = join!(async {
59 - println!("{}", &y);
59 + println!("{y}");
60 60 1
61 61 })
62 62 .await;

Lines changed: 2 additions & 2 deletions

Original file line number Diff line number Diff line change
@@ -1544,10 +1544,10 @@ impl fmt::Debug for Literal {
1544 1544 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1545 1545 f.debug_struct("Literal")
1546 1546 // format the kind on one line even in {:#?} mode
1547 -.field("kind", &format_args!("{:?}", &self.0.kind))
1547 +.field("kind", &format_args!("{:?}", self.0.kind))
1548 1548 .field("symbol", &self.0.symbol)
1549 1549 // format `Some("...")` on one line even in {:#?} mode
1550 -.field("suffix", &format_args!("{:?}", &self.0.suffix))
1550 +.field("suffix", &format_args!("{:?}", self.0.suffix))
1551 1551 .field("span", &self.0.span)
1552 1552 .finish()
1553 1553 }

Lines changed: 1 addition & 1 deletion

Original file line number Diff line number Diff line change
@@ -683,7 +683,7 @@ fn recursive_rmdir_toctou() {
683 683 let drop_canary_arc = Arc::new(());
684 684 let drop_canary_weak = Arc::downgrade(&drop_canary_arc);
685 685
686 -eprintln!("x: {:?}", &victim_del_path);
686 +eprintln!("x: {victim_del_path:?}");
687 687
688 688 // victim just continuously removes `victim_del`
689 689 thread::spawn(move |

Lines changed: 1 addition & 1 deletion

Original file line number Diff line number Diff line change
@@ -775,7 +775,7 @@ impl Error {
775 775 ///
776 776 /// impl Display for MyError {
777 777 /// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
778 - /// write!(f, "MyError: {}", &self.v)
778 + /// write!(f, "MyError: {}", self.v)
779 779 /// }
780 780 /// }
781 781 ///