[llvm-dev] RFC: Should SmallVectors be smaller?

Duncan P. N. Exon Smith via llvm-dev llvm-dev at lists.llvm.org
Sat Jun 23 11:35:45 PDT 2018



> On Jun 23, 2018, at 11:27, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:
> 
>> The patch LGTM, but why would someone actually have a SmallVector with N = 0?  Isn’t that a vector?
> 
> It's a vector that can be passed as a SmallVectorImpl parameter.  But yeah, mostly misguided.
> 

There's another explanation given in llvm/include/llvm/ADT/IndexedMap.h:
```
template <typename T, typename ToIndexT = identity<unsigned>>
  class IndexedMap {
    using IndexT = typename ToIndexT::argument_type;
    // Prefer SmallVector with zero inline storage over std::vector. IndexedMaps
    // can grow very large and SmallVector grows more efficiently as long as T
    // is trivially copyable.
    using StorageT = SmallVector<T, 0>;

```
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180623/16298af6/attachment.html>


More information about the llvm-dev mailing list