This would be useful for AttributesComponent::findMatchingAttributes to return values without allocating in most scenarios
It would have a signature like:
SmallVector<T, DefaultSize> vec;
Beyond the DefaultSize allocations will still be allowed but the vector will move to the heap. Ideally this would use a small-string-style optimization.
Example storage
struct ShortData {
std::array<T, DefaultSize> data;
};
struct LongData {
std::vector<T> data;
};
Storage storage; // union/variant of ShortData/LongData
T* data; // To make data access non-branching?
size_t size; // To make .size() calls non-branching
This would be useful for
AttributesComponent::findMatchingAttributes
to return values without allocating in most scenariosIt would have a signature like:
Beyond the DefaultSize allocations will still be allowed but the vector will move to the heap. Ideally this would use a small-string-style optimization.
Example storage