TL;DR: SmallVector now chooses a default "N", and we recommend using that default. We hope that this will - Avoid semi-arbitrary choices for the "N" parameter. - Save you extra edit/compile cycles for forgotten "N" parameters. - Avoid some of the pathological cases of SmallVector use (like sizeof(SmallVector) becoming excessively large) The programmer's manual has been updated, and now reads In the absence of a well-motivated choice for the number of inlined elements N, it is recommended to use SmallVector<T> (that is, omitting the N). This will choose a default number of inlined elements reasonable for allocation on the stack (for example, trying to keep sizeof(SmallVector<T>) around 64 bytes). https://llvm.org/docs/ProgrammersManual.html#llvm-adt-smallvector-h We haven't planned any big refactoring to use the new default, so we are expecting it to catch on organically in new code / code reviews / refactorings. Enjoy! :) For historical reference: This landed in https://reviews.llvm.org/D92522 after much discussion on the list <https://groups.google.com/g/llvm-dev/c/Z-VwNCTRGSg/m/fYi0JHhzAwAJ> and an earlier attempt at a patch <https://reviews.llvm.org/D90884> which went back and forth on various ideas, including more general aspirations for SmallVector's evolution. -- Sean Silva -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201207/deb5f741/attachment.html>
Chris Lattner via llvm-dev
2020-Dec-08 06:55 UTC
[llvm-dev] PSA: SmallVector<T> Just Works
Awesome, thank you Sean! -Chris> On Dec 7, 2020, at 1:32 PM, Sean Silva via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > TL;DR: SmallVector now chooses a default "N", and we recommend using that default. > > We hope that this will > - Avoid semi-arbitrary choices for the "N" parameter. > - Save you extra edit/compile cycles for forgotten "N" parameters. > - Avoid some of the pathological cases of SmallVector use (like sizeof(SmallVector) becoming excessively large) > > The programmer's manual has been updated, and now reads > > In the absence of a well-motivated choice for the number of inlined elements N, it is recommended to use SmallVector<T> (that is, omitting the N). This will choose a default number of inlined elements reasonable for allocation on the stack (for example, trying to keep sizeof(SmallVector<T>) around 64 bytes). > > https://llvm.org/docs/ProgrammersManual.html#llvm-adt-smallvector-h <https://llvm.org/docs/ProgrammersManual.html#llvm-adt-smallvector-h> > > We haven't planned any big refactoring to use the new default, so we are expecting it to catch on organically in new code / code reviews / refactorings. > > Enjoy! :) > > For historical reference: This landed in https://reviews.llvm.org/D92522 <https://reviews.llvm.org/D92522> after much discussion on the list <https://groups.google.com/g/llvm-dev/c/Z-VwNCTRGSg/m/fYi0JHhzAwAJ> and an earlier attempt at a patch <https://reviews.llvm.org/D90884> which went back and forth on various ideas, including more general aspirations for SmallVector's evolution. > > -- Sean Silva > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201207/735b2027/attachment.html>