Use NonNull pointer in heap version#298
Use NonNull pointer in heap version#298bors-servo merged 1 commit intoservo:masterfrom AngelicosPhosphoros:use_non_null
NonNull pointer in heap version#298Conversation
|
Also, I think this changes make Another thing is Btw, it seems that CI is broken probably because latest version of Ubuntu doesn't have some packages used in CI. |
Since `SmallVec` allocate on heap only if capacity is larger than inner capacity and therefore larger than 1, it cannot be null. Also, this is same behaviour as `std::vec::Vec` which always uses non-null pointer, which is dangling if it has zero capacity. This change reduces size of enum in some cases because it can exploit [niche optimization](https://rust-lang.github.io/unsafe-code-guidelines/glossary.html#niche). For example, `size_of::<SmallVec<[u8; 8]>>` is 24 bytes with changes from this PR while before it was 32 bytes. Also: 1. Changed some internal APIs to indicate that we work with non-nullable pointers. 2. Updated natvis and fixed bug with incorrect calculation of `is_inline` intrinsic.
|
@mbrubeck And as I tested, natvis for union version didn't work in first place because windbg cannot read I also added |
|
Thanks, this looks good! I'm going to give it one more careful review before merging it, in the next few days. |
|
@bors-servo r+ |
|
📌 Commit 9d96d7f has been approved by |
|
☀️ Test successful - checks-github |
1 similar comment
|
☀️ Test successful - checks-github |
|
I suspect that this PR increases the code size of |
Since
SmallVecallocate on heap only if capacity is larger than inner capacity and therefore larger than 1, it cannot be null. Also, this is same behaviour asstd::vec::Vecwhich always uses non-null pointer, which is dangling if it has zero capacity.This change reduces size of enum in some cases because it can exploit niche optimization. For example,
size_of::<SmallVec<[u8; 8]>>is 24 bytes with changes from this PR while before it was 32 bytes.Also:
is_inlineintrinsic.