r/rust • u/TheProgrammar89 • Jul 26 '19
Is this comment about the reference counting performance in Rust accurate?
/r/ProgrammerHumor/comments/b274zp/oof/eirvecs?context=3
47
Upvotes
r/rust • u/TheProgrammar89 • Jul 26 '19
View all comments
Show parent comment
2
u/simonask_ Jul 27 '19
Good point about drop flags being equivalent to the "moved-from" state in C++ containers and smart pointers. I hadn't thought of that, and it's a compelling excuse for an otherwise surprisingly magic quirk.
Just want to point out that you can certainly generate more code in all cases to do exactly the same thing as drop flags. In your example, the compiler can simply emit "More code" twice, one for each outcome of the condition.
It's going to be much larger in terms of code size, and probably not worth it, but C++ compilers frequently end up generating different variants of a function's tail end.