]> granicus.if.org Git - postgis/commitdiff
Slight performance tweak to remove repeated points
authorPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 22 Sep 2015 19:51:58 +0000 (19:51 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 22 Sep 2015 19:51:58 +0000 (19:51 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@14084 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/ptarray.c

index b4716417a5b45d257fadec6b09c9a29fe749e4fb..6a8bfff5a04c94f8b6189ea90bdd530edfce8be8 100644 (file)
@@ -1406,6 +1406,7 @@ ptarray_remove_repeated_points(POINTARRAY *in, double tolerance)
        size_t ptsize;
        size_t ipn, opn;
        const POINT2D *last_point, *this_point;
+       double tolsq = tolerance * tolerance;
 
        LWDEBUGF(3, "%s called", __func__);
 
@@ -1431,7 +1432,7 @@ ptarray_remove_repeated_points(POINTARRAY *in, double tolerance)
                this_point = getPoint2d_cp(in, ipn);
                if ( (ipn == in->npoints-1 && opn==1) || 
                     (tolerance == 0 && memcmp(getPoint_internal(in, ipn-1), getPoint_internal(in, ipn), ptsize) != 0) ||
-                    (tolerance > 0.0 && distance2d_pt_pt(last_point, this_point) > tolerance) )
+                    (tolerance > 0.0 && distance2d_sqr_pt_pt(last_point, this_point) > tolsq) )
                {
                        /* The point is different from the previous,
                         * we add it to output */