-
Couldn't load subscription status.
- Fork 1.4k
optimize ZStream.toInputStream #3599
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great.
|
|
||
| def testStream(assertion: java.io.InputStream => TestResult): ZIO[Any, Nothing, TestResult] = | ||
| ZIO | ||
| .foreach(List(1, 2, 5, 30)) { chunkSize => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to use a generator here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a generator and ended-up removing all my hand-written machinery.
Thanks!
| import zio.{ Chunk, Exit, FiberFailure, ZIO } | ||
|
|
||
| private[zio] class ZInputStream(chunks: Iterator[Chunk[Byte]]) extends java.io.InputStream { | ||
| private var current: Iterator[Byte] = Iterator.empty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get rid of this and keep the current chunk and offsets in a var? This will box the bytes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work!
|
@iravid thanks for kind words! |
closes #3491