Skip to content

Make SmallVector more general-purpose #37371

Closed
@nnethercote

Description

@nnethercote

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().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions