[geos-commits] [SCM] GEOS branch master updated. 9f1d3ed589a7e6f9c810a2b8a01fc79bca1ea07d

git at osgeo.org git at osgeo.org
Fri Sep 13 11:14:15 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, master has been updated
       via  9f1d3ed589a7e6f9c810a2b8a01fc79bca1ea07d (commit)
       via  4f71e7b5741180f501531ae4b826410b2585c681 (commit)
      from  0d6b39f5e6df426af38aa33f8d26d47b8674d391 (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 9f1d3ed589a7e6f9c810a2b8a01fc79bca1ea07d
Merge: 4f71e7b 0d6b39f
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Fri Sep 13 11:13:57 2019 -0700

    Merge branch 'master' of https://git.osgeo.org/gogs/geos/geos


commit 4f71e7b5741180f501531ae4b826410b2585c681
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Fri Sep 13 11:13:32 2019 -0700

    Use std::array instead of std::vector in TopologyLocation.cpp
    References #986

diff --git a/NEWS b/NEWS
index 7381e1a..2e4ebbf 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,7 @@ Changes in 3.8.0
   - Improve performance of Delaunay triangulations / Voronoi Diagrams
     (Dan Baston)
   - Improve robustness of Delaunay triangulations (Paul Ramsey, Martin Davis)
+  - Improve overlay performance (Paul Ramsey)
 
 
 Changes in 3.7.2
diff --git a/include/geos/geomgraph/TopologyLocation.h b/include/geos/geomgraph/TopologyLocation.h
index d56803d..7618ffb 100644
--- a/include/geos/geomgraph/TopologyLocation.h
+++ b/include/geos/geomgraph/TopologyLocation.h
@@ -26,6 +26,7 @@
 #include <geos/geom/Location.h>
 
 #include <vector>
+#include <array>
 #include <string>
 
 #ifdef _MSC_VER
@@ -66,8 +67,6 @@ public:
 
     ~TopologyLocation();
 
-    TopologyLocation(const std::vector<int>& newLocation);
-
     /** \brief
      * Constructs a TopologyLocation specifying how points on, to the
      * left of, and to the right of some GraphComponent relate to some
@@ -116,7 +115,7 @@ public:
     void setLocation(geom::Location locValue);
 
     /// Warning: returns reference to owned memory
-    const std::vector<geom::Location>& getLocations() const;
+    const std::array<geom::Location, 3>& getLocations() const;
 
     void setLocations(geom::Location on, geom::Location left, geom::Location right);
 
@@ -132,7 +131,8 @@ public:
 
 private:
 
-    std::vector<geom::Location> location;
+    std::array<geom::Location, 3> location;
+    std::size_t locationSize;
 };
 
 std::ostream& operator<< (std::ostream&, const TopologyLocation&);
diff --git a/src/geomgraph/TopologyLocation.cpp b/src/geomgraph/TopologyLocation.cpp
index a7e0918..e3e337a 100644
--- a/src/geomgraph/TopologyLocation.cpp
+++ b/src/geomgraph/TopologyLocation.cpp
@@ -26,19 +26,12 @@
 #include <iostream>
 #include <cassert>
 
-using namespace std;
 using namespace geos::geom;
 
 namespace geos {
 namespace geomgraph { // geos.geomgraph
 
 /*public*/
-TopologyLocation::TopologyLocation(const vector<int>& newLocation):
-    location(newLocation.size(), Location::UNDEF)
-{
-}
-
-/*public*/
 TopologyLocation::TopologyLocation()
 {
 }
@@ -50,7 +43,7 @@ TopologyLocation::~TopologyLocation()
 
 /*public*/
 TopologyLocation::TopologyLocation(Location on, Location left, Location right):
-    location(3)
+    locationSize(3)
 {
     location[Position::ON] = on;
     location[Position::LEFT] = left;
@@ -59,15 +52,17 @@ TopologyLocation::TopologyLocation(Location on, Location left, Location right):
 
 /*public*/
 TopologyLocation::TopologyLocation(Location on):
-    location(1, on)
+    locationSize(1)
 {
-    //(*location)[Position::ON]=on;
+    location.fill(Location::UNDEF);
+    location[Position::ON] = on;
 }
 
 /*public*/
 TopologyLocation::TopologyLocation(const TopologyLocation& gl)
     :
-    location(gl.location)
+    location(gl.location),
+    locationSize(gl.locationSize)
 {
 }
 
@@ -76,6 +71,7 @@ TopologyLocation&
 TopologyLocation::operator= (const TopologyLocation& gl)
 {
     location = gl.location;
+    locationSize = gl.locationSize;
     return *this;
 }
 
@@ -84,7 +80,7 @@ Location
 TopologyLocation::get(size_t posIndex) const
 {
     // should be an assert() instead ?
-    if(posIndex < location.size()) {
+    if(posIndex < locationSize) {
         return location[posIndex];
     }
     return Location::UNDEF;
@@ -94,7 +90,7 @@ TopologyLocation::get(size_t posIndex) const
 bool
 TopologyLocation::isNull() const
 {
-    for(size_t i = 0, sz = location.size(); i < sz; ++i) {
+    for(size_t i = 0; i < locationSize; ++i) {
         if(location[i] != Location::UNDEF) {
             return false;
         }
@@ -106,7 +102,7 @@ TopologyLocation::isNull() const
 bool
 TopologyLocation::isAnyNull() const
 {
-    for(size_t i = 0, sz = location.size(); i < sz; ++i) {
+    for(size_t i = 0; i < locationSize; ++i) {
         if(location[i] == Location::UNDEF) {
             return true;
         }
@@ -125,21 +121,21 @@ TopologyLocation::isEqualOnSide(const TopologyLocation& le, int locIndex) const
 bool
 TopologyLocation::isArea() const
 {
-    return location.size() > 1;
+    return locationSize > 1;
 }
 
 /*public*/
 bool
 TopologyLocation::isLine() const
 {
-    return location.size() == 1;
+    return locationSize == 1;
 }
 
 /*public*/
 void
 TopologyLocation::flip()
 {
-    if(location.size() <= 1) {
+    if(locationSize <= 1) {
         return;
     }
     std::swap(location[Position::LEFT], location[Position::RIGHT]);
@@ -149,16 +145,14 @@ TopologyLocation::flip()
 void
 TopologyLocation::setAllLocations(Location locValue)
 {
-    for(size_t i = 0, sz = location.size(); i < sz; ++i) {
-        location[i] = locValue;
-    }
+    location.fill(locValue);
 }
 
 /*public*/
 void
 TopologyLocation::setAllLocationsIfNull(Location locValue)
 {
-    for(size_t i = 0, sz = location.size(); i < sz; ++i) {
+    for(size_t i = 0; i < locationSize; ++i) {
         if(location[i] == Location::UNDEF) {
             location[i] = locValue;
         }
@@ -180,7 +174,7 @@ TopologyLocation::setLocation(Location locValue)
 }
 
 /*public*/
-const vector<Location>&
+const std::array<Location, 3>&
 TopologyLocation::getLocations() const
 {
     return location;
@@ -190,7 +184,7 @@ TopologyLocation::getLocations() const
 void
 TopologyLocation::setLocations(Location on, Location left, Location right)
 {
-    assert(location.size() >= 3);
+    assert(locationSize >= 3);
     location[Position::ON] = on;
     location[Position::LEFT] = left;
     location[Position::RIGHT] = right;
@@ -200,7 +194,7 @@ TopologyLocation::setLocations(Location on, Location left, Location right)
 bool
 TopologyLocation::allPositionsEqual(Location loc) const
 {
-    for(size_t i = 0, sz = location.size(); i < sz; ++i) {
+    for(size_t i = 0; i < locationSize; ++i) {
         if(location[i] != loc) {
             return false;
         }
@@ -213,24 +207,24 @@ void
 TopologyLocation::merge(const TopologyLocation& gl)
 {
     // if the src is an Area label & and the dest is not, increase the dest to be an Area
-    size_t sz = location.size();
-    size_t glsz = gl.location.size();
+    size_t sz = locationSize;
+    size_t glsz = gl.locationSize;
     if(glsz > sz) {
-        location.resize(3);
+        locationSize = 3;
         location[Position::LEFT] = Location::UNDEF;
         location[Position::RIGHT] = Location::UNDEF;
     }
-    for(size_t i = 0; i < sz; ++i) {
+    for(size_t i = 0; i < locationSize; ++i) {
         if(location[i] == Location::UNDEF && i < glsz) {
             location[i] = gl.location[i];
         }
     }
 }
 
-string
+std::string
 TopologyLocation::toString() const
 {
-    stringstream ss;
+    std::stringstream ss;
     ss << *this;
     return ss.str();
 }
@@ -238,11 +232,11 @@ TopologyLocation::toString() const
 std::ostream&
 operator<< (std::ostream& os, const TopologyLocation& tl)
 {
-    if(tl.location.size() > 1) {
+    if(tl.locationSize > 1) {
         os << tl.location[Position::LEFT];
     }
     os << tl.location[Position::ON];
-    if(tl.location.size() > 1) {
+    if(tl.locationSize > 1) {
         os << tl.location[Position::RIGHT];
     }
     return os;

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

Summary of changes:
 NEWS                                      |  1 +
 include/geos/geomgraph/TopologyLocation.h |  8 ++---
 src/geomgraph/TopologyLocation.cpp        | 58 ++++++++++++++-----------------
 3 files changed, 31 insertions(+), 36 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list