Skip to content

Conversation

mhermier
Copy link
Contributor

Exposing these List methods allow to grow the underlying container to a size reducing unnecessary allocations and copying, and can bring performance when the final size/required capacity of the list is known in advance.

@ruby0x1
Copy link
Member

ruby0x1 commented Nov 30, 2022

List.filled is related fwiw

@PureFox48
Copy link
Contributor

A problem with List.filled is that sometimes you don't know how much capacity you'll need when creating the list.

This PR would enable us to increase the capacity subsequently in 'one hit' and, as it doesn't add much extra code, I think it would be worth doing.

@mhermier
Copy link
Contributor Author

List.filled(_,_) as 2 side effect that this patch does not have. It does provides an internal buffer and List of the exact size. Even adding a removeAll() would be me costly to implement in user than what is provided here.

List.filled(_,_) could be extended to have a capacity argument, but I'm not sure if it is worth it.

@ruby0x1
Copy link
Member

ruby0x1 commented Nov 30, 2022

(related doesn't mean instead of, I'm aware of the value of the patch!)

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.

3 participants