Skip to content

Commit

Permalink
Update runtime/src/main/scala/org/apache/pekko/grpc/internal/ByteStri…
Browse files Browse the repository at this point in the history
…ngInputStream.scala

Co-authored-by: João Ferreira <[email protected]>
  • Loading branch information
pjfanning and jtjeferreira authored May 20, 2024
1 parent 4630e9d commit 95db7e9
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ private[internal] object ByteStringInputStream {
}

private def legacyConvert(bs: ByteString): InputStream = bs match {
case cs: ByteString1C =>
getInputStreamUnsafe(cs)
case bytestrings: ByteStrings =>
new SequenceInputStream(bytestrings.iterator.map(_.asInputStream).asJavaEnumeration)
case _ =>
// NOTE: We actually measured recently, and compact + use array was pretty good usually
legacyConvert(bs.compact)
new ByteArrayInputStream(bs.toArrayUnsafe())
}

private def getInputStreamUnsafe(bs: ByteString): InputStream =
Expand Down

0 comments on commit 95db7e9

Please sign in to comment.