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

Implement more efficient grow/shrink/realloc methods #98

Open
rusty122 opened this issue Mar 26, 2021 · 0 comments
Open

Implement more efficient grow/shrink/realloc methods #98

rusty122 opened this issue Mar 26, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@rusty122
Copy link

Motivation

The Allocator trait provides grow() shrink() and grow_zeroed() but they are implemented naively - shink for example allocates new memory, copies over bytes, and deallocates the old block of memory. realloc can be implemented for the GlobalAlloc trait with grow() and shrink() under the hood.

Proposed Solution

Implement these traits in a more efficient way with the knowledge that wee_alloc has. grow for example, may be able to extend out the existing block of memory if the next cell is free. Maybe hide this behind a feature if it adds an appreciable amount of code bloat.

Would be helpful to have a benchmark here to see what the improvements are like. I imagine that things like pushing onto a vector in a loop ends up calling realloc quite a bit as the vector grows.

@rusty122 rusty122 added the enhancement New feature or request label Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant