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

Optimize Chunk#toArray #7851

Merged
merged 1 commit into from
Feb 25, 2023
Merged

Optimize Chunk#toArray #7851

merged 1 commit into from
Feb 25, 2023

Conversation

adamgfraser
Copy link
Contributor

We should be able to efficiently copy array backed chunks even after slicing.

right.toArray(n + left.length, dest)
override protected[zio] def toArray[A1 >: A](srcPos: Int, dest: Array[A1], destPos: Int, length: Int): Unit = {
val n = math.max(math.min(math.min(length, left.length - srcPos), dest.length - destPos), 0)
left.toArray(srcPos, dest, destPos, n)
Copy link
Contributor

Choose a reason for hiding this comment

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

We could skip this call completely if srcPos > left.length (the length is needed for the next line anyway)

@jdegoes jdegoes merged commit 31c7a85 into zio:series/2.x Feb 25, 2023
@adamgfraser adamgfraser deleted the toarray branch March 8, 2023 00:44
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.

None yet

3 participants