diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2021-11-26 13:39:05 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2021-11-26 19:30:35 +1100 |
| commit | f3bda74d363a060ade5e5caeb654ba59bfed51a4 (patch) | |
| tree | 8a4b9f1307eb89a2d34a967447d341b6d28f0211 /library/alloc/src/raw_vec/tests.rs | |
| parent | 026edbb4ef85ef3d38876548a771b7c72c87803f (diff) | |
| download | rust-f3bda74d363a060ade5e5caeb654ba59bfed51a4.tar.gz rust-f3bda74d363a060ade5e5caeb654ba59bfed51a4.zip | |
Optimize `Layout::array`.
The current implementation is much more conservative than it needs to
be, because it's dealing with the size and alignment of a given `T`,
which are more restricted than an arbitrary `Layout`.
For example, imagine a struct with a `u32` and a `u4`. You can safely
create a `Layout { size_: 5, align_: 4 }` by hand, but
`Layout::new::<T>` will give `Layout { size_: 8, align_: 4}`, where the
size already has padding that accounts for the alignment. (And the
existing `debug_assert_eq!` in `Layout::array` already demonstrates that
no additional padding is required.)
Diffstat (limited to 'library/alloc/src/raw_vec/tests.rs')
0 files changed, 0 insertions, 0 deletions
