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 withAll on MutableIntStackFactoryImpl and ImmutableIntStackFactoryImpl #1379

Open
TheJavaGuy opened this issue Aug 24, 2022 · 4 comments
Assignees

Comments

@TheJavaGuy
Copy link
Contributor

TheJavaGuy commented Aug 24, 2022

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
Copy link
Contributor Author

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.

@donraab
Copy link
Contributor

donraab commented Aug 24, 2022

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

@aditya-32
Copy link

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

@TheJavaGuy
Copy link
Contributor Author

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

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

3 participants