3 ms·
RVO and NRVO are supposed to happen, as far as I know, which is why I said it in the book. Compiler bugs do happen. But also, from that thread: https://www.red
by steveklabnik 8y ago
RVO and NRVO are supposed to happen, as far as I know, which is why I said it in the book. Compiler bugs do happen.
But also, from that thread: https://www.reddit.com/r/rust/comments/8ts6b4/is_anyone_else_worried_of_performance_issues_due/e1bt47w/ https://www.reddit.com/r/rust/comments/8ts6b4/is_anyone_else...
For example: https://godbolt.org/g/DTMQM5 https://godbolt.org/g/DTMQM5 (or https://godbolt.org/g/LHMgHr https://godbolt.org/g/LHMgHr with C side-by-side) (and yes, I know that char != u8, this is just for demonstration purposes)
here, you have
mov rdi, rsp
call example::hello@PLT
not a memcpy. Right? Looks the same as the C version that takes char*.
- cwzwarich 8y ago[stupid comment]
- deleted 8y ago[deleted]
- steveklabnik 8y agoIsn’t that the array initialization?
- noncoml 8y agoI think something else is going on here, because I shouldn't be allowed to call `hello(name)` twice if it was a move, should I? https://godbolt.org/g/qUuETC https://godbolt.org/g/qUuETC
- steveklabnik 8y agoArrays are Copy when T is Copy. u8 is Copy.
- noncoml 8y agoAh.. I see, thanks for correcting me! Obviously I don't know enough Rust to argue about this. So, is something like this(https://godbolt.org/g/1ugxcW https://godbolt.org/g/1ugxcW) a inefficiency of the optimizer that we should hope to see fixed at some point?
- steveklabnik 8y agoI think so, yes.