-
Notifications
You must be signed in to change notification settings - Fork 14k
Specialize Vec::clone_from for Copy types
#87913
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
This should improve performance and reduce code size. This also improves `clone_from` for `String`, `OsString` and `PathBuf`.
|
r? @dtolnay (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
dtolnay
left a comment
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.
Looks good. SpecCloneFrom needs to be feature gated on not(no_global_oom_handling) though to fix the failed build.
error[E0599]: no method named `extend_from_slice` found for mutable reference `&mut Vec<T, A>` in the current scopeThis should improve performance and reduce code size.
Would you be able to put together a microbenchmark measuring either of these things?
|
Here is a godbolt link for comparison: https://rust.godbolt.org/z/6oGTYs9Ys Specialization removes a branch and a |
|
@bors r+ |
|
📌 Commit 94d6b22 has been approved by |
|
☀️ Test successful - checks-actions |
This should improve performance and reduce code size.
This also improves
clone_fromforString,OsStringandPathBuf.