Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider cheaper conversion between Vec #48

Open
the8472 opened this issue Jul 3, 2023 · 0 comments
Open

Consider cheaper conversion between Vec #48

the8472 opened this issue Jul 3, 2023 · 0 comments

Comments

@the8472
Copy link

the8472 commented Jul 3, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant