File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -604,9 +604,15 @@ use crate::string;
604604#[ cfg( not( no_global_oom_handling) ) ]
605605#[ must_use]
606606#[ stable( feature = "rust1" , since = "1.0.0" ) ]
607+ #[ inline]
607608pub fn format ( args : Arguments < ' _ > ) -> string:: String {
608- let capacity = args. estimated_capacity ( ) ;
609- let mut output = string:: String :: with_capacity ( capacity) ;
610- output. write_fmt ( args) . expect ( "a formatting trait implementation returned an error" ) ;
611- output
609+ #[ cold]
610+ fn format_cold ( args : Arguments < ' _ > ) -> string:: String {
611+ let capacity = args. estimated_capacity ( ) ;
612+ let mut output = string:: String :: with_capacity ( capacity) ;
613+ output. write_fmt ( args) . expect ( "a formatting trait implementation returned an error" ) ;
614+ output
615+ }
616+
617+ args. as_str ( ) . map_or_else ( || format_cold ( args) , crate :: borrow:: ToOwned :: to_owned)
612618}
You can’t perform that action at this time.
0 commit comments