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 and an earlier attempt at a patch which went back and forth on various ideas, including more general aspirations for SmallVector’s evolution.
– Sean Silva