Am I right to assume that the only thing that "slows down" Rcs is that it checks whether to deallocate the object when it drops? Besides that, "how much" is the overhead of dereferencing a Rc, i.e. should I be concerned about it?
Are those two functions almost equally fast? Or is there a notable difference in speed?
fn test_with_box() {
let b = Box::new(1.0);
let x = b * 2;
}
fn test_with_rc() {
let rc = Rc::new(1.0);
let x = rc * 2;
}
Since the referenced object in test_with_rc() always only has one reference and behaves like a Box in that function (viewed from outside, not internally, of course).
I suspect that Rcs are actually faster than I think.
PS: When talking about "fast" I mean both dereferencing and allocating/deallocating.