harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r618657 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c
Date Tue, 05 Feb 2008 14:08:41 GMT
Author: hindessm
Date: Tue Feb  5 06:08:40 2008
New Revision: 618657

URL: http://svn.apache.org/viewvc?rev=618657&view=rev
Log:
Avoid array copy if there are no changes to the original (zeroed) outFlags
array.

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c?rev=618657&r1=618656&r2=618657&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c
Tue Feb  5 06:08:40 2008
@@ -241,6 +241,7 @@
  * Class:     org_apache_harmony_luni_platform_OSNetworkSystem
  * Method:    selectImpl
  * Signature: ([Ljava/io/FileDescriptor;[Ljava/io/FileDescriptor;II[IJ)I
+ * Assumption: outFlags is zeroed
  */
 JNIEXPORT jint JNICALL Java_org_apache_harmony_luni_platform_OSNetworkSystem_selectImpl	
   (JNIEnv * env, jclass	thisClz, jobjectArray readFDArray, jobjectArray	writeFDArray,
@@ -287,24 +288,23 @@
   result = poll(my_pollfds, n_pollfds, timeout);
 
   if (result > 0) {
+          int changed = 0; /* Record if we actually change the IntArray */
 	  /* output result to int array */
-	  flagArray = (*env)->GetIntArrayElements(env,outFlags,	&isCopy);
+	  flagArray = (*env)->GetIntArrayElements(env, outFlags, &isCopy);
 	  for (val=0; val<countReadC; val++) {
           if (my_pollfds[val].revents & (POLLIN | POLLPRI)) {
               flagArray[val] = SOCKET_OP_READ;
-          } else {
-              flagArray[val] = SOCKET_OP_NONE;
+              changed=1;
           }
       }
 
 	  for (val=0; val<countWriteC; val++) {
           if (my_pollfds[val+countReadC].revents & POLLOUT) {
               flagArray[val+countReadC] = SOCKET_OP_WRITE;
-          } else {
-              flagArray[val+countReadC] = SOCKET_OP_NONE;
+              changed=1;
           }
       }
-      (*env)->ReleaseIntArrayElements(env, outFlags, flagArray, 0);
+          (*env)->ReleaseIntArrayElements(env, outFlags, flagArray, changed ? 0 : JNI_ABORT);
   }
   hymem_free_memory(my_pollfds);
   



Mime
View raw message