From c765c63125db63b674139a4e4bf44fce59240fbd Mon Sep 17 00:00:00 2001 From: hasufell Date: Fri, 31 Oct 2014 17:49:08 +0100 Subject: [PATCH] POLYINT: run rmdups only once --- Algorithms/PolygonIntersection/Core.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Algorithms/PolygonIntersection/Core.hs b/Algorithms/PolygonIntersection/Core.hs index 26d2768..0f32d9f 100644 --- a/Algorithms/PolygonIntersection/Core.hs +++ b/Algorithms/PolygonIntersection/Core.hs @@ -105,12 +105,12 @@ sortLexPolys _ = [] -- |Get all points that intersect between both polygons. This is done -- in O(n). intersectionPoints :: [PolyPT] -> [PT] -intersectionPoints [] = [] -intersectionPoints xs' = - rmdups $ - (++) (segIntersections . scanLine $ xs') - (intersectionPoints (tail xs')) +intersectionPoints xs' = rmdups . go $ xs' where + go [] = [] + go xs = (++) (segIntersections . scanLine $ xs) + (go (tail xs)) + -- Get the scan line or in other words the -- Segment pairs we are going to check for intersection. scanLine :: [PolyPT] -> ([Segment], [Segment])