SmallVector is a very useful type. It can avoid lots of heap allocations when used on hot paths, which can give nice speed-ups. I have used it in multiple places, and I have more changes in the pipeline that will use it.
But it's not quite as general-purpose as it could be. Ideas for improvement:
- Rename it as
SmallVec, to mirror Vec.
- Move it from libsyntax to librustc_data_structures.
- Increase the number of elements that can be present without requiring heap allocation from 1 to 2 or 4. (Because 1 covers a lot of cases, but 2 or 4 would cover more.)
- Tweak the API to better match
Vec. E.g. change zero() to new().