From 8b4a3462df143725b4526f097737c227521c7c3d Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Tue, 22 Sep 2015 19:51:58 +0000 Subject: [PATCH] Slight performance tweak to remove repeated points git-svn-id: http://svn.osgeo.org/postgis/trunk@14084 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/ptarray.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/liblwgeom/ptarray.c b/liblwgeom/ptarray.c index b4716417a..6a8bfff5a 100644 --- a/liblwgeom/ptarray.c +++ b/liblwgeom/ptarray.c @@ -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 */ -- 2.50.1