harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From regi...@apache.org
Subject svn commit: r817180 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSMemory.c
Date Mon, 21 Sep 2009 07:39:23 GMT
Author: regisxu
Date: Mon Sep 21 07:39:17 2009
New Revision: 817180

URL: http://svn.apache.org/viewvc?rev=817180&view=rev
Log:
Apply patch for HARMONY-6257: [classlib][luni] - Optimize OSMemory.get/setByteArray

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSMemory.c

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSMemory.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSMemory.c?rev=817180&r1=817179&r2=817180&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSMemory.c (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSMemory.c Mon
Sep 21 07:39:17 2009
@@ -66,10 +66,7 @@
   (JNIEnv * env, jobject thiz, jlong address, jbyteArray byteArray,
    jint offset, jint length)
 {
-  jboolean isCopy;
-  jbyte *bytes = (*env)->GetByteArrayElements (env, byteArray, &isCopy);
-  memcpy (bytes + offset, (const void *) ((IDATA) address), (size_t) length);
-  (*env)->ReleaseByteArrayElements (env, byteArray, bytes, 0);
+  (*env)->SetByteArrayRegion(env, byteArray, offset, length, (jbyte *) ((IDATA) address));
 }
 
 JNIEXPORT void JNICALL Java_org_apache_harmony_luni_platform_OSMemory_setByteArray
@@ -77,10 +74,10 @@
    jint offset, jint length)
 {
   jboolean isCopy;
-  jbyte *bytes = (*env)->GetByteArrayElements (env, byteArray, &isCopy);
+  jbyte *bytes = (*env)->GetPrimitiveArrayCritical(env, byteArray, &isCopy);
   memcpy ((void *) ((IDATA) address),
 	  (const jbyte *) ((IDATA) bytes + offset), (size_t) length);
-  (*env)->ReleaseByteArrayElements (env, byteArray, bytes, JNI_ABORT);
+  (*env)->ReleaseByteArrayElements(env, byteArray, bytes, JNI_ABORT);
 }
 
 JNIEXPORT jbyte JNICALL Java_org_apache_harmony_luni_platform_OSMemory_getByte



Mime
View raw message