[Vegan-commits] r1815 - pkg/vegan/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Sep 9 20:52:33 CEST 2011


Author: jarioksa
Date: 2011-09-09 20:52:32 +0200 (Fri, 09 Sep 2011)
New Revision: 1815

Modified:
   pkg/vegan/src/nestedness.c
Log:
get out quickly from isDiag* if there is nothing to do

Modified: pkg/vegan/src/nestedness.c
===================================================================
--- pkg/vegan/src/nestedness.c	2011-09-09 12:48:31 UTC (rev 1814)
+++ pkg/vegan/src/nestedness.c	2011-09-09 18:52:32 UTC (rev 1815)
@@ -179,12 +179,16 @@
 	    if (sm[i] > 0)
 		    sX++;
 
+    /* quick return if there really is nothing to do */
+    if (sX == 0)
+        return 0;
+
     /* Smallest diagonal and antidiagonal element */
     choose[0] = (sm[1] < sm[2]) ? sm[1] : sm[2];
     choose[1] = (sm[0] < sm[3]) ? -sm[0] : -sm[3]; 
 
     if (sX == 4) {
-        /* Either choose could be returned, but RNG is not needed,
+	 /* Either choose could be returned, but RNG is not needed, 
 	 * because sm already is in random order, and we always return
 	 * choose[0] */
 	    return choose[0];
@@ -320,6 +324,8 @@
 	if (sm[i] > 0)
 	    sX++;
 
+    if (sX == 0)
+	return 0;
     if (sX == 4) {
 	return 1;
     }



More information about the Vegan-commits mailing list