-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
IArray: from_iter optimization for empty arrays #48
IArray: from_iter optimization for empty arrays #48
Conversation
Does Rust not optimize |
hmm it's true that a collection of 0 elements collected to a vec will not allocate. But it does make an Rc for nothing I guess |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have no quick way to benchmark these changes, it is fine then lol
I copy-pasted the divan thingy from yew to see and oh wow it's terribly faster: After:
Before:
(I need to rename the test file I know :D) |
The one for single element is also impressive: Before:
After:
|
I just noticed that Rc has a from_iter to
(The others are better but it's good to have it for collections that have more than 1 items!) |
@kirillsemyonkin I don't really want to do all the CI stuff for now to display a comment with the benchmark -_- but I'm already happy with the results of the benchmarks. If it's good for you I will merge. |
This will optimize creation of IArray from an empty iterator.
Also added a constant
IArray<T>::EMPTY
.