eclipse-collections
eclipse-collections copied to clipboard
Optimize withAll on MutableIntSetFactoryImpl and ImmutableIntSetFactoryImpl
The code currently in withAll on both mutable and immutable implementations calls toArray on IntStream which if the Stream is very large can be extremely expensive and won't take advantage of a Set's ability to store only unique elements.
Current mutable factory code:
public MutableIntSet withAll(IntStream items)
{
return this.with(items.toArray());
}
Current immutable factory code:
public ImmutableIntSet withAll(IntStream items)
{
return this.with(items.toArray());
}
Hey @donraab How can I help here? Can you please explain to me a bit more about this because I am new to the eclipse collection
Hi @gaurangkudale, thank you for the questions and your interest in Eclipse Collections! I always recommend starting by working through the Eclipse Collections Katas to understand the library if you haven't used it before.
https://github.com/eclipse/eclipse-collections-kata
You'll probably have gotten an idea of how things work after the Pet Kata and that may be enough to get started. The other katas will continue to build up new or reinforce existing knowledge about the library.
I can this assign the issue to you if you are interested in working on this. There is also a great blog about making a first contribution to Eclipse Collections from a first time contributor.
https://mydeveloperplanet.com/2021/01/20/how-to-start-contributing-to-open-source/
Hope this helps.
Hi @donraab Thans for information I'd like to work on this issue
Thanks for volunteering @gaurangkudale! I've assigned the issue to you.
@donraab hey - what optimization did you have in mind here? trying to do a distinct on the stream perhaps or
Just add the elements directly from the IntStream to a MutableIntSet. In the ImmutableIntSet case, create a MutableIntSet from the IntStream and call toImmutable() at the end.