[PATCH] D40210: [libc++] Shrink varient's index type when possible

Eric Fiselier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 18 12:38:02 PST 2017


EricWF created this revision.

Currently `std::variant` always uses an unsigned int to store the variant index. However this isn't nessesary and causes `std::variant` to be larger than it needs to be in most cases.

This patch changes the index type to be `unsigned char` when possible, and `unsigned short` or `unsigned int` otherwise, depending on the size (Although it's questionable if it's even possible to create a variant with 65535 elements.

Unfortunately this change is an ABI break, and as such is only enabled in ABI v2.


https://reviews.llvm.org/D40210

Files:
  include/__config
  include/variant
  test/libcxx/utilities/variant/variant.variant/variant_size.pass.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40210.123470.patch
Type: text/x-patch
Size: 6491 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171118/9670b2d4/attachment.bin>


More information about the cfe-commits mailing list