4 ms·
It's because of the libraries. They get compiled once.
by worldsavior 4y ago
It's because of the libraries. They get compiled once.
- steveklabnik 4y agoIt’s because they don’t have the same semantics, you are adding overhead with the Rust version in multiple ways.
- scotty79 4y agoI wonder how much difference there would be if I used shared_ptr in C++ instead of the bare one. EDIT: As far as I can tell less than 190 lines of asm but I don't know shared_ptr enough to produce exactly the same code.
- steveklabnik 4y agoYeah, that gets closer for sure. refcell is still going to add a bit of state to the value inside of the allocation, but at least the shared_ptr and Rc/Arc bits are the same semantic, so it'll be closer!
- worldsavior 4y agoLook at the asm code of rust. You would see that most of the code there is the libraries (and yeah, also because of the semantics, which are powerful).
- steveklabnik 4y ago... the library that implements those different semantics. If you wrote your own Rc and RefCell, that code would still exist, in your crate. Where it lives isn't the root cause.