[PATCH] ADT: Shave a pointer off of SmallVector<T, 1>

Duncan P. N. Exon Smith dexonsmith at apple.com
Tue Jun 30 17:34:34 PDT 2015


I'd just commit this, but I want to check:

 1. Are my static asserts valid under MSVC?  Sanitizers?  If not, what
    *is* a portable way to check that we don't waste memory here?
 2. I like them in SmallVector.h (assuming they're portable).
    Anyone strongly prefer ADTTests?

Avoid an unused byte -- which for `sizeof(T) >= sizeof(void *)` costs
a pointer -- on `SmallVector<T, 1>`.  Shave the same byte off of
`SmallVector<T, 0>`.  Otherwise, no functionality change.

Note that `SmallVector<T, 0>` has the same memory footprint as
`SmallVector<T, 1>`, which seems like a bug to me.  We should probably
fix that too.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ADT-Shave-a-pointer-off-of-SmallVector-T-1-NFC.patch
Type: application/octet-stream
Size: 5122 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150630/66602f96/attachment.obj>


More information about the llvm-commits mailing list