Skip to content

Commit 690b641

Browse files
authored
Merge pull request #3331 from armanbilge/topic/optimize-bytevector-toarrayslice
Use `toByteBufferUnsafe` in `toArraySlice`
2 parents 11ffd3d + 9154dd8 commit 690b641

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

core/shared/src/main/scala/fs2/Chunk.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,9 +1085,7 @@ object Chunk
10851085
def toByteVector() = bv
10861086

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

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

0 commit comments

Comments
 (0)