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

Optimize slices #96

Open
jjg-123 opened this issue Jan 21, 2025 · 0 comments
Open

Optimize slices #96

jjg-123 opened this issue Jan 21, 2025 · 0 comments

Comments

@jjg-123
Copy link
Collaborator

jjg-123 commented Jan 21, 2025

(low level stuff) ow slices are created by appending values to an ArrayList. This means that the backing array is repeatedly copied and expanded as needed. Far better is to do the actual math that estimates the number of elements and allocate it ahead of time, simply filling in the values as they are computed. For very large slices, this makes a lot of difference in speed.

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