[PATCH] D90884: [SmallVector] Add a default small size.

Duncan P. N. Exon Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 11 11:40:32 PST 2020


dexonsmith added a comment.

In D90884#2387157 <https://reviews.llvm.org/D90884#2387157>, @silvas wrote:

> In D90884#2387127 <https://reviews.llvm.org/D90884#2387127>, @mehdi_amini wrote:
>
>> Random other proposal in the brainstorming here: introduce a subclass `llvm::Vector` that inherit from SmallVector and define the size as never exceeding 64B. `SmallVector` would always have an explicit size and `Vector` never: that at least address the case someone using `SmallVector<LargeSize>` and getting an implicit and unexpected `N=0`
>
> Interesting idea! What do other folks think? That would make average code even more succinct (no "Small").
>
> My only concern would be llvm::Vector sounds to me like something that would never have inlined elements, but this proposal would mean that sometimes it has a inlined elements.
>
> Mehdi, so I can better understand your position, your main objection is for something called "SmallVector" to have zero inlined elements unless explicitly requested?

If we add an `llvm::Vector` I think it should be:

  template <class T> using Vector = SmallVector<T, 0>;

rather than "no more than 64B".

One option would be to also add:

  template <class T> using DefaultSmallVector = SmallVector<T, kDefaultSmallSize<T>>;

(maybe with a better name), for Sean's use case of "give me a little bit of local storage if it's not expensive".


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90884/new/

https://reviews.llvm.org/D90884



More information about the llvm-commits mailing list