Skip to content

Commit

Permalink
improve send performance
Browse files Browse the repository at this point in the history
GetByteArrayElements is not efficient with big-size java byte array.
  • Loading branch information
liebo committed Apr 19, 2014
1 parent b1e7b07 commit 87e96c8
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/main/c++/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,15 +692,9 @@ JNIEXPORT jboolean JNICALL Java_org_zeromq_ZMQ_00024Socket_send (JNIEnv *env,
raise_exception (env, err);
return JNI_FALSE;
}

jbyte *data = env->GetByteArrayElements (msg, 0);
if (! data) {
raise_exception (env, EINVAL);
return JNI_FALSE;
}

memcpy (zmq_msg_data (&message), data + offset, length);
env->ReleaseByteArrayElements (msg, data, 0);

void* pd = zmq_msg_data (&message);
env->GetByteArrayRegion(msg, offset, length, (jbyte*) pd);
#if ZMQ_VERSION >= ZMQ_MAKE_VERSION(3,0,0)
rc = zmq_sendmsg (s, &message, flags);
#else
Expand Down

0 comments on commit 87e96c8

Please sign in to comment.