You are viewing a plain text version of this content. The canonical link for it is here.
Posted to juice-svn@xml.apache.org by ra...@apache.org on 2006/01/13 18:08:36 UTC

svn commit: r368787 - in /incubator/juice/native/src: md5.c sha-1.c

Author: raul
Date: Fri Jan 13 09:08:29 2006
New Revision: 368787

URL: http://svn.apache.org/viewcvs?rev=368787&view=rev
Log:
OPTIMIZATION: Use the fastest getPrimitiveArrayCritical

Modified:
    incubator/juice/native/src/md5.c
    incubator/juice/native/src/sha-1.c

Modified: incubator/juice/native/src/md5.c
URL: http://svn.apache.org/viewcvs/incubator/juice/native/src/md5.c?rev=368787&r1=368786&r2=368787&view=diff
==============================================================================
--- incubator/juice/native/src/md5.c (original)
+++ incubator/juice/native/src/md5.c Fri Jan 13 09:08:29 2006
@@ -29,16 +29,16 @@
 #include "digest.h"
 
 JNIEXPORT jbyteArray JNICALL 
-Java_org_apache_security_jce_MD5_digest(JNIEnv *env, jobject obj, jbyteArray input) {
+Java_org_apache_security_jce_MD5_digest(JNIEnv *env, jclass obj, jbyteArray input) {
 
-	jbyte *inputBytes = (*env)->GetByteArrayElements(env, input, NULL);
+	
 	jsize arrayLength = (*env)->GetArrayLength(env, input);
 	jbyteArray jb;
 	unsigned char md[MD5_DIGEST_LENGTH];
-
+	jbyte *inputBytes = (*env)->GetPrimitiveArrayCritical(env, input, NULL);
 	_juice_evp_digest (inputBytes, arrayLength, md, NULL, EVP_md5());
 
-	(*env)->ReleaseByteArrayElements(env, input, inputBytes, JNI_ABORT);
+	(*env)->ReleasePrimitiveArrayCritical(env, input, inputBytes, JNI_ABORT);
 
 	jb = (*env)->NewByteArray(env, MD5_DIGEST_LENGTH);
 	(*env)->SetByteArrayRegion(env, jb, 0, MD5_DIGEST_LENGTH, (jbyte *)md);

Modified: incubator/juice/native/src/sha-1.c
URL: http://svn.apache.org/viewcvs/incubator/juice/native/src/sha-1.c?rev=368787&r1=368786&r2=368787&view=diff
==============================================================================
--- incubator/juice/native/src/sha-1.c (original)
+++ incubator/juice/native/src/sha-1.c Fri Jan 13 09:08:29 2006
@@ -31,14 +31,14 @@
 JNIEXPORT jbyteArray JNICALL 
 Java_org_apache_security_jce_SHA_digest1(JNIEnv *env, jobject obj, jbyteArray input) {
 
-	jbyte *inputBytes = (*env)->GetByteArrayElements(env, input, NULL);
+	
 	jsize arrayLength = (*env)->GetArrayLength(env, input);
 	jbyteArray jb;
 	unsigned char md[SHA_DIGEST_LENGTH];
-
+	jbyte *inputBytes = (*env)->GetPrimitiveArrayCritical(env, input, NULL);
 	_juice_evp_digest (inputBytes, arrayLength, md, NULL, EVP_sha1());
 
-	(*env)->ReleaseByteArrayElements(env, input, inputBytes, JNI_ABORT);
+	(*env)->ReleasePrimitiveArrayCritical(env, input, inputBytes, JNI_ABORT);
 
 	jb = (*env)->NewByteArray(env, SHA_DIGEST_LENGTH);
 	(*env)->SetByteArrayRegion(env, jb, 0, SHA_DIGEST_LENGTH, (jbyte *)md);
@@ -51,14 +51,14 @@
 }
 JNIEXPORT jlong JNICALL Java_org_apache_security_jce_SHA_update
   (JNIEnv *env, jclass cl, jbyteArray input, jint offset, jint lon, jlong handle) {
-  jbyte *inputBytes = (*env)->GetByteArrayElements(env, input, NULL);
+
   if (handle==0) {
   	handle=(jlong)_juice_evp_create(EVP_sha1());
   }
-  printf("poraqui");
+  jbyte *inputBytes = (*env)->GetPrimitiveArrayCritical(env, input, NULL);
   _juice_evp_update ((void*)(inputBytes+offset), lon,
 					  (EVP_MD_CTX  *)handle);
-  (*env)->ReleaseByteArrayElements(env, input, inputBytes, JNI_ABORT);					  
+  (*env)->ReleasePrimitiveArrayCritical(env, input, inputBytes, JNI_ABORT);					  
   return handle;
 }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: juice-svn-unsubscribe@xml.apache.org
For additional commands, e-mail: juice-svn-help@xml.apache.org