Reduce use of ByteBuf{Input,Output}Stream in Js5Compression

Probably slightly more efficient.

Signed-off-by: Graham <gpe@openrs2.dev>
Graham 4 years ago
parent 8887b0a1e9
commit ce97775663
  1. 8
      cache/src/main/java/dev/openrs2/cache/Js5Compression.kt

@ -33,9 +33,7 @@ object Js5Compression {
val start = output.writerIndex()
type.createOutputStream(ByteBufOutputStream(output)).use { outputStream ->
ByteBufInputStream(input).use { inputStream ->
inputStream.copyTo(outputStream)
}
input.readBytes(outputStream, input.readableBytes())
}
val len = output.writerIndex() - start
@ -103,9 +101,7 @@ object Js5Compression {
plaintext.alloc().buffer(uncompressedLen, uncompressedLen).use { output ->
type.createInputStream(ByteBufInputStream(plaintext, len), uncompressedLen).use { inputStream ->
ByteBufOutputStream(output).use { outputStream ->
inputStream.copyTo(outputStream)
}
output.writeBytes(inputStream, output.writableBytes())
}
return output.retain()

Loading…
Cancel
Save