[llvm-dev] PSA: SmallVector<T> Just Works
Geoffrey Martin-Noble via llvm-dev
llvm-dev at lists.llvm.org
Thu Nov 4 09:27:18 PDT 2021
Just an update on this that the same is now true of `to_vector` with
https://reviews.llvm.org/D112968, so you can write `to_vector` without
template arguments in the common case where the value type is inferrable.
On Mon, Dec 7, 2020 at 10:55 PM Chris Lattner via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> 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
>
> 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
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
> _______________________________________________
> 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/20211104/4736b60e/attachment.html>
More information about the llvm-dev
mailing list