Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@adamgfraser
Copy link
Contributor

No description provided.

@adamgfraser adamgfraser requested review from jdegoes and vigoo March 28, 2023 16:29
}
final def isEmpty: Boolean = {
@tailrec
def loop(cause: Cause[E], stack: List[Cause[E]]): Boolean =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I almost feel it's a mistake to make all the Cause operations stack safe, because of the overhead in allocation.

But anyway, this seems a good change. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about the same thing. Unfortunately I do think that users sometimes create very large nested causes, for example using collectAllPar. Hopefully the check for reference equality with the empty cause covers the vast majority of "happy path" cases and we are really only doing this when a failure has occurred.

One alternative would be to ensure that we construct a balanced tree so that we never reach a sufficient depth where we need to be stack safe similar to what we do with Chunk. This would have some complexities with the fact that Cause has both a Both and a Then case but it is something we could explore.

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.

2 participants