Skip to content

Commit

Permalink
use ByString.toArrayUnsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning committed May 18, 2024
1 parent 28b854d commit 1431101
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ object Gzip extends Codec {
override def compress(uncompressed: ByteString): ByteString = {
val baos = new ByteArrayOutputStream(uncompressed.size)
val gzos = new GZIPOutputStream(baos)
try gzos.write(uncompressed.toArray)
try gzos.write(uncompressed.toArrayUnsafe())
finally gzos.close()
ByteString.fromArrayUnsafe(baos.toByteArray)
}

override def uncompress(compressed: ByteString): ByteString = {
val gzis = new GZIPInputStream(new ByteArrayInputStream(compressed.toArray))
val gzis = new GZIPInputStream(new ByteArrayInputStream(compressed.toArrayUnsafe()))

val baos = new ByteArrayOutputStream(compressed.size)
val buffer = new Array[Byte](32 * 1024)
Expand Down

0 comments on commit 1431101

Please sign in to comment.