[geos-commits] [SCM] GEOS branch 3.8 updated. 3fbafe067f43ad7f40d0539ecdb7dd2286e8c6fb

git at osgeo.org git at osgeo.org
Thu Oct 10 12:36:58 PDT 2019


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".

The branch, 3.8 has been updated
       via  3fbafe067f43ad7f40d0539ecdb7dd2286e8c6fb (commit)
      from  76a252a57c1db863436c91a8217098159a7fdc7a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 3fbafe067f43ad7f40d0539ecdb7dd2286e8c6fb
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Thu Oct 10 12:36:39 2019 -0700

    Stack allocate line segments in OverlapUnion

diff --git a/NEWS b/NEWS
index 38038ab..770c9b0 100644
--- a/NEWS
+++ b/NEWS
@@ -2,7 +2,7 @@ Changes in 3.8.1
 2019-xx-xx
 
 - Bug fixes / improvements
-  - 
+  - Stack allocate line segments in OverlapUnion (Paul Ramsey)
 
 
 Changes in 3.8.0
diff --git a/include/geos/operation/union/OverlapUnion.h b/include/geos/operation/union/OverlapUnion.h
index c3f35b1..1c72bcd 100644
--- a/include/geos/operation/union/OverlapUnion.h
+++ b/include/geos/operation/union/OverlapUnion.h
@@ -113,9 +113,9 @@ private:
     std::unique_ptr<geom::Geometry> unionFull(const geom::Geometry* geom0, const geom::Geometry* geom1);
     std::unique_ptr<geom::Geometry> unionBuffer(const geom::Geometry* geom0, const geom::Geometry* geom1);
     bool isBorderSegmentsSame(const geom::Geometry* result, const geom::Envelope& env);
-    bool isEqual(std::vector<geom::LineSegment*>& segs0, std::vector<geom::LineSegment*>& segs1);
-    std::vector<geom::LineSegment*> extractBorderSegments(const geom::Geometry* geom0, const geom::Geometry* geom1, const geom::Envelope& env);
-    void extractBorderSegments(const geom::Geometry* geom, const geom::Envelope& penv, std::vector<geom::LineSegment*>& psegs);
+    bool isEqual(std::vector<geom::LineSegment>& segs0, std::vector<geom::LineSegment>& segs1);
+    std::vector<geom::LineSegment> extractBorderSegments(const geom::Geometry* geom0, const geom::Geometry* geom1, const geom::Envelope& env);
+    void extractBorderSegments(const geom::Geometry* geom, const geom::Envelope& penv, std::vector<geom::LineSegment>& psegs);
 
 };
 
diff --git a/src/operation/union/OverlapUnion.cpp b/src/operation/union/OverlapUnion.cpp
index 8f21660..49f43c4 100644
--- a/src/operation/union/OverlapUnion.cpp
+++ b/src/operation/union/OverlapUnion.cpp
@@ -138,27 +138,22 @@ OverlapUnion::unionBuffer(const Geometry* geom0, const Geometry* geom1)
 bool
 OverlapUnion::isBorderSegmentsSame(const Geometry* result, const Envelope& env)
 {
-    std::vector<LineSegment*> segsBefore = extractBorderSegments(g0, g1, env);
-    std::vector<LineSegment*> segsAfter;
+    std::vector<LineSegment> segsBefore = extractBorderSegments(g0, g1, env);
+    std::vector<LineSegment> segsAfter;
     extractBorderSegments(result, env, segsAfter);
-    //std::cout << ("# seg before: " << segsBefore.size() << " - # seg after: " << segsAfter.size() << std::endl;
     bool eq = isEqual(segsBefore, segsAfter);
 
-    // Clean up temporary segment arrays
-    for (auto seg : segsBefore) delete seg;
-    for (auto seg : segsAfter) delete seg;
-
     return eq;
 }
 
-static bool lineSegmentPtrCmp(const LineSegment* a, const LineSegment* b)
+static bool lineSegmentPtrCmp(const LineSegment& a, const LineSegment& b)
 {
-    return a->compareTo(*b) < 0;
+    return a.compareTo(b) < 0;
 }
 
 /* private */
 bool
-OverlapUnion::isEqual(std::vector<LineSegment*>& segs0, std::vector<LineSegment*>& segs1)
+OverlapUnion::isEqual(std::vector<LineSegment>& segs0, std::vector<LineSegment>& segs1)
 {
     if (segs0.size() != segs1.size())
         return false;
@@ -168,10 +163,10 @@ OverlapUnion::isEqual(std::vector<LineSegment*>& segs0, std::vector<LineSegment*
 
     size_t sz = segs0.size();
     for (std::size_t i = 0; i < sz; i++) {
-        if (segs0[i]->p0.x != segs1[i]->p0.x ||
-            segs0[i]->p0.y != segs1[i]->p0.y ||
-            segs0[i]->p1.x != segs1[i]->p1.x ||
-            segs0[i]->p1.y != segs1[i]->p1.y)
+        if (segs0[i].p0.x != segs1[i].p0.x ||
+            segs0[i].p0.y != segs1[i].p0.y ||
+            segs0[i].p1.x != segs1[i].p1.x ||
+            segs0[i].p1.y != segs1[i].p1.y)
         {
             return false;
         }
@@ -181,10 +176,10 @@ OverlapUnion::isEqual(std::vector<LineSegment*>& segs0, std::vector<LineSegment*
 }
 
 /* private */
-std::vector<LineSegment*>
+std::vector<LineSegment>
 OverlapUnion::extractBorderSegments(const Geometry* geom0, const Geometry* geom1, const Envelope& env)
 {
-    std::vector<LineSegment*> segs;
+    std::vector<LineSegment> segs;
     extractBorderSegments(geom0, env, segs);
     if (geom1 != nullptr)
         extractBorderSegments(geom1, env, segs);
@@ -218,17 +213,17 @@ containsProperly(const Envelope& env, const Coordinate& p0, const Coordinate& p1
 
 /* privatef */
 void
-OverlapUnion::extractBorderSegments(const Geometry* geom, const Envelope& penv, std::vector<LineSegment*>& psegs)
+OverlapUnion::extractBorderSegments(const Geometry* geom, const Envelope& penv, std::vector<LineSegment>& psegs)
 {
     class BorderSegmentFilter : public CoordinateSequenceFilter {
 
     private:
         const Envelope env;
-        std::vector<LineSegment*>* segs;
+        std::vector<LineSegment>* segs;
 
     public:
 
-        BorderSegmentFilter(const Envelope& penv, std::vector<LineSegment*>* psegs)
+        BorderSegmentFilter(const Envelope& penv, std::vector<LineSegment>* psegs)
             : env(penv),
               segs(psegs) {};
 
@@ -248,7 +243,7 @@ OverlapUnion::extractBorderSegments(const Geometry* geom, const Envelope& penv,
             const Coordinate& p1 = seq.getAt(i  );
             bool isBorder = intersects(env, p0, p1) && ! containsProperly(env, p0, p1);
             if (isBorder) {
-                segs->push_back(new LineSegment(p0, p1));
+                segs->emplace_back(p0, p1);
             }
         };
 

-----------------------------------------------------------------------

Summary of changes:
 NEWS                                        |  2 +-
 include/geos/operation/union/OverlapUnion.h |  6 ++---
 src/operation/union/OverlapUnion.cpp        | 35 +++++++++++++----------------
 3 files changed, 19 insertions(+), 24 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list