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

Lazily initialize backing store of Vector #90

Merged
merged 8 commits into from
Feb 10, 2024
Merged

Conversation

smarr
Copy link
Owner

@smarr smarr commented Feb 7, 2024

During the discussion of #84 the initialization strategy of Vector was discussed.
Before this PR, it would create an array of 50 elements in the default case.

This PR changes Vector to not create an array at the beginning, and instead initialize the storage with null. The access operations are adapted to check for null where needed and initialize the storage array on demand.

The size of the initial array is also decreased to 10. This choice is made mostly based on results from large program corpuses where people found that arrays tent to be small, usually have few elements. Though, I didn't investigate what the size distribution for our benchmarks here is.

The PR also has a few other minor cleanups.

@smarr smarr mentioned this pull request Feb 7, 2024
@smarr smarr force-pushed the empty-initial-vector branch from eb41111 to 78f407d Compare February 10, 2024 23:15
@smarr smarr merged commit 387ecd0 into master Feb 10, 2024
20 checks passed
@smarr smarr deleted the empty-initial-vector branch February 10, 2024 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant