Uh oh!
There was an error while loading. Please reload this page.
Override clone_from method for PathBuf and OsString - #84615
Conversation
rust-highfive
commented
Apr 27, 2021
(rust-highfive has picked a reviewer for you, use r? to override) |
jyn514
commented
Apr 27, 2021
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 fnclone_from(&mutself,source:&Self){*self = source.clone();}In case of an Example comparison between |
jyn514
commented
Apr 28, 2021
I don't understand why that's the case? You're still calling clone on the buffer. |
No, the new implementation calls |
jyn514
commented
Apr 28, 2021
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. |
Mark-Simulacrum
commented
Apr 28, 2021
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 |
bors
commented
Apr 28, 2021
📌 Commit 4a8671a has been approved by |
a1phyr
commented
Apr 28, 2021
Yes, for derives #27939 was closed because of compile time. For individual items in |
bors
commented
Apr 28, 2021
bors
commented
Apr 29, 2021
☀️ Test successful - checks-actions |
This was not the case before because
#[derive(Clone)]do not do it.