about summary refs log tree commit diff
path: root/src/test/debuginfo/enum-thinlto.rs
diff options
context:
space:
mode:
authorMike Hommey <mh@glandium.org>2018-03-30 16:10:47 +0900
committerMike Hommey <mh@glandium.org>2018-04-02 10:10:12 +0900
commitcc939ac345091327b23f807b7d1f6a7c75c03f36 (patch)
treead2c1f70d3c5f7390371ed42271dd526bbe59044 /src/test/debuginfo/enum-thinlto.rs
parent06fa27d7c84a21af8449e06f3c50b243c4d5a7ad (diff)
downloadrust-cc939ac345091327b23f807b7d1f6a7c75c03f36.tar.gz
rust-cc939ac345091327b23f807b7d1f6a7c75c03f36.zip
Add vec![ptr::null{,_mut}(); n] optimization, like vec![0; n]
vec![0; n], via implementations of SpecFromElem, has an optimization
that uses with_capacity_zeroed instead of with_capacity, which will use
calloc instead of malloc, and avoid an extra memset.

This adds the same optimization for vec![ptr::null(); n] and
vec![ptr::null_mut(); n], assuming their bit value is 0 (which is true
on all currently supported platforms).

This does so by adding an intermediate trait IsZero, which looks very
much like nonzero::Zeroable, but that one is on the way out, and doesn't
apply to pointers anyways.

Adding such a trait allows to avoid repeating the logic using
with_capacity_zeroed or with_capacity, or making the macro more complex
to support generics.
Diffstat (limited to 'src/test/debuginfo/enum-thinlto.rs')
0 files changed, 0 insertions, 0 deletions