diff options
| author | bors <bors@rust-lang.org> | 2018-07-29 09:33:37 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-07-29 09:33:37 +0000 |
| commit | 023fd7e74a9eb5bafcb75fcbe69b7110e9de4492 (patch) | |
| tree | c9b50228b27509d45f6d73e33aaec6b482c80c36 /src/libsyntax | |
| parent | a5c2d0fffaaf0b764c01bc4066e51ffd475ceae9 (diff) | |
| parent | 57a5a9b05423c4f832cd9a3aaa7e06d55fab6efa (diff) | |
| download | rust-023fd7e74a9eb5bafcb75fcbe69b7110e9de4492.tar.gz rust-023fd7e74a9eb5bafcb75fcbe69b7110e9de4492.zip | |
Auto merge of #52767 - ljedrz:avoid_format, r=petrochenkov
Prefer to_string() to format!() Simple benchmarks suggest in some cases it can be faster by even 37%: ``` test converting_f64_long ... bench: 339 ns/iter (+/- 199) test converting_f64_short ... bench: 136 ns/iter (+/- 34) test converting_i32_long ... bench: 87 ns/iter (+/- 16) test converting_i32_short ... bench: 87 ns/iter (+/- 49) test converting_str ... bench: 54 ns/iter (+/- 15) test formatting_f64_long ... bench: 349 ns/iter (+/- 176) test formatting_f64_short ... bench: 145 ns/iter (+/- 14) test formatting_i32_long ... bench: 98 ns/iter (+/- 14) test formatting_i32_short ... bench: 93 ns/iter (+/- 15) test formatting_str ... bench: 86 ns/iter (+/- 23) ```
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index b84046d1050..9f8909e1626 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -380,7 +380,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { structs, enums and unions"); if let ast::AttrStyle::Inner = attr.style { let trait_list = traits.iter() - .map(|t| format!("{}", t)).collect::<Vec<_>>(); + .map(|t| t.to_string()).collect::<Vec<_>>(); let suggestion = format!("#[derive({})]", trait_list.join(", ")); err.span_suggestion_with_applicability( span, "try an outer attribute", suggestion, @@ -558,7 +558,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { invoc.expansion_data.mark.set_expn_info(ExpnInfo { call_site: attr.span, def_site: None, - format: MacroAttribute(Symbol::intern(&format!("{}", attr.path))), + format: MacroAttribute(Symbol::intern(&attr.path.to_string())), allow_internal_unstable: false, allow_internal_unsafe: false, local_inner_macros: false, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 56760546c50..9011b6e48b9 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -6320,7 +6320,7 @@ impl<'a> Parser<'a> { mod_name: mod_name.clone(), default_path: default_path_str, secondary_path: secondary_path_str, - dir_path: format!("{}", dir_path.display()), + dir_path: dir_path.display().to_string(), }), (true, true) => Err(Error::DuplicatePaths { mod_name: mod_name.clone(), diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 08c9ec4c989..54ce06f61ef 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -631,7 +631,7 @@ pub trait PrintState<'a> { self.writer().word(&ut.val_to_string(i)) } ast::LitIntType::Unsuffixed => { - self.writer().word(&format!("{}", i)) + self.writer().word(&i.to_string()) } } } |
