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

Add .shrink_to_fit() for Array #1424

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add .shrink_to_fit() for Array #1424

wants to merge 1 commit into from

Conversation

bluss
Copy link
Member

@bluss bluss commented Aug 18, 2024

Add .shrink_to_fit() for owned storage arrays.
This initial version does not change array strides, this is to avoid the most tricky part of the implementation (and maybe take it step by step).

Care must be taken since self.ptr points inside the allocation - which for Array is still Vec-allocated, and several Vec methods including its shrink_to_fit can reallocate the array.

@bluss
Copy link
Member Author

bluss commented Aug 18, 2024

This is a new take on #1141. I don't think this is an easy topic, lots of details to work through. That's also why this change (in current state) does not change the Array strides.

@bluss bluss force-pushed the shrink-to-fit-2 branch 3 times, most recently from 1e561b9 to 9688513 Compare August 18, 2024 11:16
Add `.shrink_to_fit()` for owned storage arrays.
This initial version does not change array strides, this is to avoid the
most tricky part of the implementation (and maybe take it step by step).

Care must be taken since `self.ptr` points inside the allocation - which
for `Array` is still `Vec`-allocated, and several Vec methods including
its `shrink_to_fit` can reallocate the array.
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

Successfully merging this pull request may close these issues.

1 participant