-
Notifications
You must be signed in to change notification settings - Fork 14.1k
alloc: specialize String::extend for slices of str #149694
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
base: main
Are you sure you want to change the base?
alloc: specialize String::extend for slices of str #149694
Conversation
|
rustbot has assigned @Mark-Simulacrum. Use |
|
@bors try @rust-timer queue |
|
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
|
⌛ Trying commit b17164a with merge 281de2c… To cancel the try build, run the command Workflow: https://github.com/rust-lang/rust/actions/runs/19975733341 |
…r=<try> alloc: specialize String::extend for slices of str
|
|
||
| #[inline] | ||
| fn push_str_slice(&mut self, slice: &[&str]) { | ||
| let additional = slice.iter().map(|x| x.len()).sum(); |
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.
This needs to check for overflow, otherwise it's unsound to do unchecked ptr.adds and copy_nonoverlappings below.
|
The job Click to see the possible cause of the failure (guessed by this bot)For more information how to resolve CI failures of this job, visit this link. |
Here's a small optimization via specialization that can potentially eliminate a fair few reallocations when building strings using specific patterns, unsure if this justifies the use of unsafe, but I had the code implemented from #148604, so I thought it was worth submitting to see.