[GRASS-SVN] r52488 - grass/trunk/lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jul 31 11:06:18 PDT 2012


Author: mmetz
Date: 2012-07-31 11:06:18 -0700 (Tue, 31 Jul 2012)
New Revision: 52488

Modified:
   grass/trunk/lib/vector/Vlib/poly.c
Log:
Vlib poly optimization

Modified: grass/trunk/lib/vector/Vlib/poly.c
===================================================================
--- grass/trunk/lib/vector/Vlib/poly.c	2012-07-31 16:50:48 UTC (rev 52487)
+++ grass/trunk/lib/vector/Vlib/poly.c	2012-07-31 18:06:18 UTC (rev 52488)
@@ -97,18 +97,15 @@
     if (*i < *j)
 	return -1;
 
-    if (*i > *j)
-	return 1;
-
-    return 0;
+    return (*i > *j);
 }
 
 static int V__within(double a, double x, double b)
 {
     if (a < b)
 	return (x >= a && x <= b);
-    else
-	return (x >= b && x <= a);
+
+    return (x >= b && x <= a);
 }
 
 /*
@@ -668,10 +665,9 @@
     if (n_intersects == -1)
 	return 2;
 
-    if (n_intersects % 2)
-	return 1;
-    else
-	return 0;
+    /* odd number of intersections: inside, return 1 
+     * even number of intersections: outside, return 0 */
+    return (n_intersects & 1);
 }
 
 /*!
@@ -743,10 +739,9 @@
 	G_debug(3, "  n_intersects = %d", n_intersects);
     }
 
-    if (n_intersects % 2)
-	return 1;
-    else
-	return 0;
+    /* odd number of intersections: inside, return 1 
+     * even number of intersections: outside, return 0 */
+    return (n_intersects & 1);
 }
 
 /*!
@@ -810,8 +805,7 @@
 	n_intersects += inter;
     }
 
-    if (n_intersects % 2)
-	return 1;
-    else
-	return 0;
+    /* odd number of intersections: inside, return 1 
+     * even number of intersections: outside, return 0 */
+    return (n_intersects & 1);
 }



More information about the grass-commit mailing list