-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Specialization for Extend<&T> for vec #38182
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
r? @alexcrichton This fix goes forward instead of backwards, you could say, by adding more specializations instead of reverting. |
Specialize to use copy_from_slice when extending a Vec with &[T] where T: Copy.
41b55da
to
02bf1ce
Compare
@bors: r+ Seems ok to me, thanks! I'd still ideally prefer to explore the route of adding codegen tests eventually (to ensure we don't regress) but that can happen in a follow-up |
📌 Commit 02bf1ce has been approved by |
Ok, there is no codegen test, but codegen for extend_with_slice was examined and was fine before it went in, so in that way it's unlikely that it would have been caught that way. It already optimized fine in many situations. |
@dtolnay This PR fixes the regression in the sense that the regression I saw here #38021 (comment) was verified to be back at its old performance at 1.5-1.6 ms/iter. I haven't done further tests. |
Specialization for Extend<&T> for vec Specialize to use copy_from_slice when extending a Vec with &[T] where T: Copy. This specialization results in `.clone()` not being called in `extend_from_slice` and `extend` when the element is `Copy`. Fixes #38021
Specialize to use copy_from_slice when extending a Vec with &[T] where
T: Copy.
This specialization results in
.clone()
not being called inextend_from_slice
andextend
when the element isCopy
.Fixes #38021