eclipse-collections icon indicating copy to clipboard operation
eclipse-collections copied to clipboard

Optimize withAll on MutableIntStackFactoryImpl and ImmutableIntStackFactoryImpl

Open TheJavaGuy opened this issue 3 years ago • 4 comments
trafficstars

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.

Current mutable factory code:

public MutableIntStack withAll(IntStream items)
{
    return this.with(items.toArray());
}

Current immutable factory code:

public ImmutableIntStack withAll(IntStream items)
{
    return this.with(items.toArray());
}

It would be much better to simply iterate over the Stream and push the results to a IntArrayStack.

TheJavaGuy avatar Aug 24 '22 15:08 TheJavaGuy

I've created this issue as a counterpart to #1372. @nikhilnanivadekar @donraab if you gentlemen agree this is worth pursuing, I could solve it in a similar manner.

TheJavaGuy avatar Aug 24 '22 15:08 TheJavaGuy

Sounds reasonable to me. I've assigned the issue to you. We can review the code when you submit a PR. Thanks!

donraab avatar Aug 24 '22 16:08 donraab

Hi @donraab can i contribute to this, if no one is working on this

aditya-32 avatar Apr 21 '23 07:04 aditya-32

@donraab If @aditya-32 wants to take this over I'm OK with it, please reassign issue to them.

TheJavaGuy avatar May 02 '23 13:05 TheJavaGuy