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

override toIterable more and use it #3967

Merged
merged 1 commit into from
Aug 18, 2021
Merged

Conversation

johnynek
Copy link
Contributor

Noticed this in #2363

We have toIterable in Foldable, but most structures were not overriding it.

Here I do that, and also use it in preference to foldRight for some default implementations in Foldable since foldRight is fundamentally hard to optimize due to the reliance on Eval[A]. By contrast, many things can implement toIterable very cheaply and we can very safely use local mutability (via .iterator) to reduce trampolining via Eval.

@djspiewak djspiewak merged commit 62801f9 into main Aug 18, 2021
@armanbilge armanbilge deleted the oscar/optimize_toiterable branch April 10, 2022 10:45
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