]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #50357 - seanmonstar:arc-weak-null, r=KodrAus
authorbors <bors@rust-lang.org>
Fri, 29 Jun 2018 04:09:02 +0000 (04:09 +0000)
committerbors <bors@rust-lang.org>
Fri, 29 Jun 2018 04:09:02 +0000 (04:09 +0000)
Arc: remove unused allocation from Weak::new()

It seems non-obvious that calling `Weak::new()` actually allocates space for the entire size of `T`, even though you can **never** access that data from such a constructed weak pointer. Besides that, if someone were to create many `Weak:new()`s, they could be unknowingly wasting a bunch of memory.

This change makes it so that `Weak::new()` allocates no memory at all. Instead, it is created with a null pointer. The only things done with a `Weak` are trying to upgrade, cloning, and dropping, meaning there are very few places that the code actually needs to check if the pointer is null.


Trivial merge