Skip to content

Consider cheaper conversion between Vec #48

@the8472

Description

@the8472

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions