Try to reduce JNI calls into compressor.

Comparatively speaking, JNI calls are very expensive, so we want to
reduce them as much as possible.
This commit is contained in:
Andrew Steinborn
2019-01-10 21:10:00 -05:00
parent e240dac55b
commit 1ddeb85f60
2 changed files with 4 additions and 4 deletions

View File

@@ -36,21 +36,21 @@ class VelocityCompressorTest {
compressor.dispose();
fail("Loaded regular compressor");
}
check(compressor, () -> Unpooled.directBuffer(TEST_DATA.length));
check(compressor, () -> Unpooled.directBuffer(TEST_DATA.length + 32));
}
@Test
void javaIntegrityCheckDirect() throws DataFormatException {
VelocityCompressor compressor = JavaVelocityCompressor.FACTORY
.create(Deflater.DEFAULT_COMPRESSION);
check(compressor, () -> Unpooled.directBuffer(TEST_DATA.length));
check(compressor, () -> Unpooled.directBuffer(TEST_DATA.length + 32));
}
@Test
void javaIntegrityCheckHeap() throws DataFormatException {
VelocityCompressor compressor = JavaVelocityCompressor.FACTORY
.create(Deflater.DEFAULT_COMPRESSION);
check(compressor, () -> Unpooled.buffer(TEST_DATA.length));
check(compressor, () -> Unpooled.buffer(TEST_DATA.length + 32));
}
private void check(VelocityCompressor compressor, Supplier<ByteBuf> bufSupplier)