From: bors Date: Fri, 29 Jun 2018 04:09:02 +0000 (+0000) Subject: Auto merge of #50357 - seanmonstar:arc-weak-null, r=KodrAus X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=3b50455c61847c4a417b5fb002a5258dbaf4a868;p=rust.git Auto merge of #50357 - seanmonstar:arc-weak-null, r=KodrAus 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. --- 3b50455c61847c4a417b5fb002a5258dbaf4a868