Skip to content

Don't format!() string literals#52805

Merged
bors merged 1 commit into
rust-lang:masterfrom
ljedrz:format_str_literal
Jul 30, 2018
Merged

Don't format!() string literals#52805
bors merged 1 commit into
rust-lang:masterfrom
ljedrz:format_str_literal

Conversation

@ljedrz

@ljedrz ljedrz commented Jul 28, 2018

Copy link
Copy Markdown
Contributor

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().

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @petrochenkov

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 28, 2018

Copy link
Copy Markdown
Member

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)

Copy link
Copy Markdown
Member

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.

@ljedrz ljedrz force-pushed the format_str_literal branch from 01bed0e to 421b2ba Compare July 28, 2018 16:03
@ljedrz

ljedrz commented Jul 28, 2018

Copy link
Copy Markdown
Contributor Author

@kennytm thanks, done.

@petrochenkov

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Jul 29, 2018

Copy link
Copy Markdown
Collaborator

📌 Commit 421b2ba has been approved by petrochenkov

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 29, 2018
@bors

bors commented Jul 29, 2018

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 421b2ba with merge 7ff3098...

bors added a commit that referenced this pull request Jul 29, 2018
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()`.
@bors

bors commented Jul 29, 2018

Copy link
Copy Markdown
Collaborator

💔 Test failed - status-appveyor

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 29, 2018
@ljedrz

ljedrz commented Jul 29, 2018

Copy link
Copy Markdown
Contributor Author

Build execution time has reached the maximum allowed time for your plan (180 minutes).

Spurious?

@kennytm

kennytm commented Jul 30, 2018

Copy link
Copy Markdown
Member

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 30, 2018
@bors

bors commented Jul 30, 2018

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 421b2ba with merge 6a3fada2b42a3fba3e4d872d555d743ab711b999...

@bors

bors commented Jul 30, 2018

Copy link
Copy Markdown
Collaborator

💔 Test failed - status-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 30, 2018
@rust-highfive

Copy link
Copy Markdown
Contributor

The job dist-mipsel-linux of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
######################################################################    97.8%
######################################################################## 100.0%
[00:00:59] extracting /checkout/obj/build/cache/2018-07-27/rust-std-beta-x86_64-unknown-linux-gnu.tar.gz
[00:00:59] downloading https://static.rust-lang.org/dist/2018-07-27/rustc-beta-x86_64-unknown-linux-gnu.tar.gz
No output has been received in the last 30m0s, this potentially indicates a stalled build or something wrong with the build itself.
Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received
The build has been terminated

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 @TimNN. (Feature Requests)

@kennytm

kennytm commented Jul 30, 2018

Copy link
Copy Markdown
Member

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 30, 2018
@bors

bors commented Jul 30, 2018

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 421b2ba with merge 988b7451140651f904f5d8147a0d4accb2f7e6c2...

@bors

bors commented Jul 30, 2018

Copy link
Copy Markdown
Collaborator

💔 Test failed - status-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 30, 2018
@rust-highfive

Copy link
Copy Markdown
Contributor

The job dist-x86_64-musl of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[01:00:56] test [run-pass] run-pass/trivial-message.rs ... ok
[01:00:56] test [run-pass] run-pass/try-operator-hygiene.rs ... ok
[01:00:57] test [run-pass] run-pass/try-macro.rs ... ok

Broadcast message from root@travis-job-feee2b13-5b2a-4a1d-ad05-039941501fc5
 (unknown) at 4:33 ...
The system is going down for power off NOW!
[01:00:57] 
[01:00:57] Session terminated, terminating shell... ...terminated.

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 143.
travis_time:start:2abf60c1
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

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 @TimNN. (Feature Requests)

@kennytm

kennytm commented Jul 30, 2018

Copy link
Copy Markdown
Member

@bors retry travis-ci/travis-ci#4924

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 30, 2018
@bors

bors commented Jul 30, 2018

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 421b2ba with merge 7bbcd00...

bors added a commit that referenced this pull request Jul 30, 2018
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()`.
@bors

bors commented Jul 30, 2018

Copy link
Copy Markdown
Collaborator

☀️ Test successful - status-appveyor, status-travis
Approved by: petrochenkov
Pushing 7bbcd00 to master...

@bors bors merged commit 421b2ba into rust-lang:master Jul 30, 2018
@ljedrz ljedrz deleted the format_str_literal branch July 30, 2018 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants