thin-vec
thin-vec copied to clipboard
Consider cheaper conversion between Vec
I realize that given the nsTArray
mentions in the documentation this is probably out of scope, so feel free to just close this, but here I go anyway:
The conversion between Vec and ThinVec could be made cheaper by
a) calculating the layout in a way that the header is a multiple of size_of::<T>
(at least for smallish T), this way turning ThinVec -> Vec would only require a memmove, not a layout change
b) turning the header into a trailer which could make the Vec -> ThinVec conversion free as long as there's enough spare capacity.
That way code could mostly deal in Vec
and benefit from its api (e.g. Splice) and only turn things into a thinvec when putting it into a size-sensitive struct.