-
Notifications
You must be signed in to change notification settings - Fork 150
Use NonNull
pointer in heap version
#298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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
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 asstd::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. For example,
size_of::<SmallVec<[u8; 8]>>
is 24 bytes with changes from this PR while before it was 32 bytes.Also:
is_inline
intrinsic.