Optimize native handling further.

We now try to work within the boundaries given by the native. In the
case of Java natives, we work with byte arrays. With natives, always use
direct buffers.

However, the numbers do favor the natives, since they work with direct
byte buffers, without any copying. For the most part, this commit is
intended to improve the lives of Velocity users on Windows.
This commit is contained in:
Andrew Steinborn
2018-12-30 06:16:04 -05:00
parent 095a478440
commit 8588e7f1fe
10 changed files with 121 additions and 57 deletions

View File

@@ -85,7 +85,7 @@ Java_com_velocitypowered_natives_compression_NativeZlibDeflate_process(JNIEnv *e
jint sourceLength,
jlong destinationAddress,
jint destinationLength,
jboolean flush)
jboolean finish)
{
z_stream* stream = (z_stream*) ctx;
stream->next_in = (Bytef *) sourceAddress;
@@ -93,7 +93,7 @@ Java_com_velocitypowered_natives_compression_NativeZlibDeflate_process(JNIEnv *e
stream->avail_in = sourceLength;
stream->avail_out = destinationLength;
int res = deflate(stream, flush ? Z_FINISH : Z_NO_FLUSH);
int res = deflate(stream, finish ? Z_FINISH : Z_NO_FLUSH);
switch (res) {
case Z_STREAM_END:
// The stream has ended.