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

Skip to content

Conversation

@paulpdaniels
Copy link
Contributor

Under the hood ZStream.absolve was using mapZIO which destroys chunking. Since the stream can only fail once with a Left this can be improved by optimizing for the happy path instead.

if (mapped.size == in.size) ZChannel.write(mapped) *> loop
else {
val firstError = in(mapped.size).asInstanceOf[Left[E, O]]
ZChannel.write(mapped) *> ZChannel.fail(firstError.value)
Copy link
Contributor Author

@paulpdaniels paulpdaniels Nov 18, 2023

Choose a reason for hiding this comment

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

Read up to the error, these values can be safely written first, then the error can be written after. This will preserve maximum chunking until the "final" chunk that terminates the stream.

@adamgfraser adamgfraser merged commit cf3ff22 into zio:series/2.x Nov 18, 2023
@paulpdaniels paulpdaniels deleted the optimize-absolve branch November 18, 2023 14:25
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