-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Override clone_from
method for PathBuf and OsString
#84615
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
What is the goal of this change? Does it improve performance at all? If not I don't see much point to it. |
The default implementation of fn clone_from(&mut self, source: &Self) {
*self = source.clone();
} In case of an Example comparison between |
I don't understand why that's the case? You're still calling clone on the buffer. |
No, the new implementation calls |
Ok, I found why I was confused: this reuses the allocation of the destination, not the source: https://doc.rust-lang.org/nightly/src/alloc/vec/mod.rs.html#2337-2366 LGTM but I'm not on T-libs and I'd prefer someone else to take a look. |
Seems likely pretty harmless but we also likely don't want to do this for everything as there is some compile-time overhead to their existence I suspect. @bors r+ rollup=never |
📌 Commit 4a8671a has been approved by |
Yes, for derives #27939 was closed because of compile time. For individual items in |
☀️ Test successful - checks-actions |
This was not the case before because
#[derive(Clone)]
do not do it.