diff --git a/boot/src/main/java/org/glavo/japp/boot/JAppReader.java b/boot/src/main/java/org/glavo/japp/boot/JAppReader.java index ec8f4ad..18016ae 100644 --- a/boot/src/main/java/org/glavo/japp/boot/JAppReader.java +++ b/boot/src/main/java/org/glavo/japp/boot/JAppReader.java @@ -272,16 +272,14 @@ private ByteBuffer decompressResource( CompressionMethod method, ByteBuffer compressed, int size) throws IOException { - - byte[] output = new byte[size]; - ByteBuffer outputBuffer = ByteBuffer.wrap(output); - switch (method) { case CLASSFILE: { + byte[] output = new byte[size]; ClassFileDecompressor.decompress(this, compressed, output); - break; + return ByteBuffer.wrap(output); } case ZSTD: { + ByteBuffer outputBuffer = ByteBuffer.allocate(size); decompressZstd(compressed, outputBuffer); outputBuffer.flip(); break; @@ -290,8 +288,6 @@ private ByteBuffer decompressResource( throw new IOException("Unsupported compression method: " + method); } } - - return outputBuffer; } private int castArrayLength(long value) { @@ -316,7 +312,7 @@ public ByteBuffer readResource(JAppResource resource) throws IOException { if (mappedBuffer != null) { compressed = ByteBufferUtils.slice(mappedBuffer, offset, compressedSize); } else { - compressed = ByteBuffer.allocate(compressedSize); + compressed = ByteBuffer.allocateDirect(compressedSize); while (compressed.hasRemaining()) { int n = channel.read(compressed, offset + baseOffset + compressed.position());