Skip to content

Commit

Permalink
Merge pull request #3331 from armanbilge/topic/optimize-bytevector-to…
Browse files Browse the repository at this point in the history
…arrayslice

Use `toByteBufferUnsafe` in `toArraySlice`
  • Loading branch information
mpilquist authored Nov 7, 2023
2 parents 11ffd3d + 9154dd8 commit 690b641
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions core/shared/src/main/scala/fs2/Chunk.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1085,9 +1085,7 @@ object Chunk
def toByteVector() = bv

override def toArraySlice[O2 >: Byte](implicit ct: ClassTag[O2]): Chunk.ArraySlice[O2] =
if (ct.runtimeClass == classOf[Byte])
Chunk.ArraySlice[Byte](bv.toArrayUnsafe, 0, size).asInstanceOf[Chunk.ArraySlice[O2]]
else super.toArraySlice
Chunk.ByteBuffer.view(bv.toByteBufferUnsafe).toArraySlice

override def toByteBuffer[B >: Byte](implicit ev: B =:= Byte): JByteBuffer =
bv.toByteBuffer
Expand Down

0 comments on commit 690b641

Please sign in to comment.