Skip to content

Don't reload length in String::push#155847

Open
DaniPopes wants to merge 1 commit intorust-lang:mainfrom
DaniPopes:string-push-len
Open

Don't reload length in String::push#155847
DaniPopes wants to merge 1 commit intorust-lang:mainfrom
DaniPopes:string-push-len

Conversation

@DaniPopes
Copy link
Copy Markdown
Contributor

@DaniPopes DaniPopes commented Apr 26, 2026

Same as in Vec::push_mut, we get .len() once at the start since it won't change in the reserve() call.

Saves reloading the length after the allocation: https://godbolt.org/z/W3G165Gd7

Same as in Vec::push_mut, we get `.len()` once at the start since
it won't change in the `reserve()` call.

Saves reloading the length after the allocation: https://godbolt.org/z/W3G165Gd7
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 26, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 26, 2026

r? @jhpratt

rustbot has assigned @jhpratt.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 6 candidates
  • Random selection from Mark-Simulacrum, jhpratt

@xtqqczze

This comment was marked as outdated.

@DaniPopes
Copy link
Copy Markdown
Contributor Author

No, these are the flags: -Ctarget-cpu=znver3 -Cpanic=abort -Copt-level=3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants