8000 Optimize `ZPipeline::mapEitherChunked` by guizmaii · Pull Request #9816 · zio/zio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Optimize ZPipeline::mapEitherChunked #9816

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

Open
wants to merge 1 commit into
base: series/2.x
Choose a base branch
from

Conversation

guizmaii
Copy link
Member

No description provided.

@guizmaii guizmaii self-assigned this Apr 22, 2025
val builder: ChunkBuilder[Out] = ChunkBuilder.make[Out](chunk.size)
val iterator: Iterator[In] = chunk.iterator
val builder: ChunkBuilder[Out] = ChunkBuilder.make[Out](size)
val iterator = chunk.chunkIterator
Copy link
Member Author

Choose a reason for hiding this comment

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

TIL about ChunkIterator

image

@guizmaii guizmaii force-pushed the opt_mapEitherChunked branch from 1c4d37d to 22a99e2 Compare April 22, 2025 10:20
@@ -1820,22 +1819,23 @@ object ZPipeline extends ZPipelinePlatformSpecificConstructors {
chunk => {
val size = chunk.size

if (size == 0) reader
Copy link
Member Author

Choose a reason for hiding this comment

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

In another PR, we were talking about the fact that this Chunk can probably never be empty

@guizmaii guizmaii requested review from ghostdogpr, hearnadam and kyri-petrou and removed request for ghostdogpr April 22, 2025 10:22
@guizmaii guizmaii force-pushed the opt_mapEitherChunked branch from 22a99e2 to 45d3afa Compare April 22, 2025 10:22
while (iterator.hasNext && (error == null)) {
val a = iterator.next()
f(a) match {
while (iterator.hasNextAt(index) && (error == null)) {
Copy link
Contributor
@kyri-petrou kyri-petrou Apr 26, 2025

Choose a reason for hiding this comment

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

I'm 99.99% sure that if you have size already stored locally you can simply iterate by checking index < size without having to call hasNextAt(index)

@kyri-petrou
Copy link
Contributor

@guizmaii happy to merge it once you apply my recommendation above :)

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
0