3 ms·
why do you x.clone()? it isn't in the C++, and that shaves off a few instructions ;)
by yababa_y 4y ago
why do you x.clone()? it isn't in the C++, and that shaves off a few instructions ;)
- codedokode 4y agoI think that there is implicit clone() in C++ code because when we pass a shared_ptr to a function, its reference count gets incremented (and decremented later) and it would be unfair if we used move instead of clone in Rust.
- maleldil 4y agoIf you don't, the Rust version will be moving the Arc, but the C++ version will be copying the shared_ptr. To make both versions comparable, you must either use Arc::clone on Rust, or use std::move on C++.