-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Don't format!() string literals #52805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
@@ -99,30 +99,26 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { | |||
let span_label_var1 = if let Some(simple_ident) = anon_arg_sup.pat.simple_ident() { | |||
format!(" from `{}`", simple_ident) | |||
} else { | |||
format!("") | |||
"".to_string() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using String::new()
instead of "".to_string()
would be even faster. (Similar for every other occurrences)
@@ -229,7 +229,7 @@ fn check_paths<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, | |||
} | |||
|
|||
fn dump_graph(tcx: TyCtxt) { | |||
let path: String = env::var("RUST_DEP_GRAPH").unwrap_or_else(|_| format!("dep_graph")); | |||
let path: String = env::var("RUST_DEP_GRAPH").unwrap_or("dep_graph".to_string()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should keep the unwrap_or_else
where. .to_string()
is not free.
01bed0e
to
421b2ba
Compare
@kennytm thanks, done. |
@bors r+ |
📌 Commit 421b2ba has been approved by |
Don't format!() string literals Prefer `to_string()` to `format!()` take 2, this time targetting string literals. In some cases (`&format!("...")` -> `"..."`) also removes allocations. Occurences of `format!("")` are changed to `String::new()`.
💔 Test failed - status-appveyor |
Spurious? |
@bors retry |
⌛ Testing commit 421b2ba with merge 6a3fada2b42a3fba3e4d872d555d743ab711b999... |
💔 Test failed - status-travis |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors retry |
⌛ Testing commit 421b2ba with merge 988b7451140651f904f5d8147a0d4accb2f7e6c2... |
💔 Test failed - status-travis |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Don't format!() string literals Prefer `to_string()` to `format!()` take 2, this time targetting string literals. In some cases (`&format!("...")` -> `"..."`) also removes allocations. Occurences of `format!("")` are changed to `String::new()`.
☀️ Test successful - status-appveyor, status-travis |
Prefer
to_string()
toformat!()
take 2, this time targetting string literals. In some cases (&format!("...")
->"..."
) also removes allocations. Occurences offormat!("")
are changed toString::new()
.