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

runtime: Mildly over-allocate when growing slices #4287

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

Conversation

lpereira
Copy link
Contributor

@lpereira lpereira commented Jun 7, 2024

This refactors runtime.sliceAppend() and runtime.sliceGrow() so, not only sliceAppend() uses sliceGrow() if needed, sliceGrow() only mildly over-allocates a new buffer using a sequence similar to what CPython uses for list objects.

CC @dgryski

This refactors runtime.sliceAppend() and runtime.sliceGrow() so, not
only sliceAppend() uses sliceGrow() if needed, sliceGrow() only mildly
over-allocates a new buffer using a sequence similar to what CPython
uses for list objects.

Signed-off-by: L. Pereira <[email protected]>
@dgryski
Copy link
Member

dgryski commented Jun 26, 2024

Some quick testing shows this makes the multiplication factor 1.125. However the expression doesn't seem to work for newCap <= 8 so I think we need to make sure the edge cases are handled properly.

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.

None yet

2 participants