[geos-commits] [SCM] GEOS branch master updated. bb01f9a1a7b795f606ac67d82845ebdd0c02e572

git at osgeo.org git at osgeo.org
Fri Jun 21 17:36:38 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  bb01f9a1a7b795f606ac67d82845ebdd0c02e572 (commit)
       via  3c9c1603ef7202543b80dd03d134d6fed756078c (commit)
       via  aff7bcf25a4879d95243c5a60240a4ee0b4a06a6 (commit)
      from  4075390d72d384a8474d5d3e60c91bfb445c1753 (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 bb01f9a1a7b795f606ac67d82845ebdd0c02e572
Merge: aff7bcf 3c9c160
Author: Daniel Baston <dbaston at gmail.com>
Date:   Fri Jun 21 20:36:24 2019 -0400

    Merge branch 'remove-virtual-inheritance'


commit 3c9c1603ef7202543b80dd03d134d6fed756078c
Author: Daniel Baston <dbaston at gmail.com>
Date:   Fri Jun 21 09:45:24 2019 -0400

    Remove virtual inheritance in Geometry subclasses
    
    Virtual inheritance is not required, increases the size of all Geometry
    subclasses by 8 bytes, and introduces a step of indirection when
    accessing Geometry members.

diff --git a/include/geos/geom/GeometryCollection.h b/include/geos/geom/GeometryCollection.h
index b1af27c..b284337 100644
--- a/include/geos/geom/GeometryCollection.h
+++ b/include/geos/geom/GeometryCollection.h
@@ -52,7 +52,7 @@ namespace geom { // geos::geom
  * represented by GeometryCollection subclasses MultiPoint,
  * MultiLineString, MultiPolygon.
  */
-class GEOS_DLL GeometryCollection : public virtual Geometry {
+class GEOS_DLL GeometryCollection : public Geometry {
 
 public:
     friend class GeometryFactory;
diff --git a/include/geos/geom/LineString.h b/include/geos/geom/LineString.h
index d56fb1a..5e0c438 100644
--- a/include/geos/geom/LineString.h
+++ b/include/geos/geom/LineString.h
@@ -65,7 +65,7 @@ namespace geom { // geos::geom
  *  If these conditions are not met, the constructors throw
  *  an {@link util::IllegalArgumentException}.
  */
-class GEOS_DLL LineString: public virtual Geometry {
+class GEOS_DLL LineString: public Geometry {
 
 public:
 
diff --git a/include/geos/geom/MultiLineString.inl b/include/geos/geom/MultiLineString.inl
index e37596e..3a3d112 100644
--- a/include/geos/geom/MultiLineString.inl
+++ b/include/geos/geom/MultiLineString.inl
@@ -31,7 +31,6 @@ namespace geom { // geos::geom
 INLINE
 MultiLineString::MultiLineString(const MultiLineString& mp)
     :
-    Geometry(mp),
     GeometryCollection(mp)
 {
 }
diff --git a/include/geos/geom/MultiPoint.h b/include/geos/geom/MultiPoint.h
index 40005de..04655a7 100644
--- a/include/geos/geom/MultiPoint.h
+++ b/include/geos/geom/MultiPoint.h
@@ -119,7 +119,7 @@ protected:
      */
     MultiPoint(std::vector<Geometry*>* newPoints, const GeometryFactory* newFactory);
 
-    MultiPoint(const MultiPoint& mp): Geometry(mp), GeometryCollection(mp) {}
+    MultiPoint(const MultiPoint& mp): GeometryCollection(mp) {}
 
     const Coordinate* getCoordinateN(size_t n) const;
 
diff --git a/include/geos/geom/MultiPolygon.inl b/include/geos/geom/MultiPolygon.inl
index 4ddb9bc..7d1b071 100644
--- a/include/geos/geom/MultiPolygon.inl
+++ b/include/geos/geom/MultiPolygon.inl
@@ -28,7 +28,6 @@ namespace geom { // geos::geom
 INLINE
 MultiPolygon::MultiPolygon(const MultiPolygon& mp)
     :
-    Geometry(mp),
     GeometryCollection(mp)
 {
 }
diff --git a/include/geos/geom/Point.h b/include/geos/geom/Point.h
index 6ba15fc..3a1d838 100644
--- a/include/geos/geom/Point.h
+++ b/include/geos/geom/Point.h
@@ -62,7 +62,7 @@ namespace geom { // geos::geom
  *   (i.e does not have an NaN X or Y ordinate)
  *
  */
-class GEOS_DLL Point : public virtual Geometry {
+class GEOS_DLL Point : public Geometry {
 
 public:
 
diff --git a/include/geos/geom/Polygon.h b/include/geos/geom/Polygon.h
index b4289cd..662d2f2 100644
--- a/include/geos/geom/Polygon.h
+++ b/include/geos/geom/Polygon.h
@@ -61,7 +61,7 @@ namespace geom { // geos::geom
  *  Specification for SQL</A> .
  *
  */
-class GEOS_DLL Polygon: public virtual Geometry {
+class GEOS_DLL Polygon: public Geometry {
 
 public:
 
diff --git a/src/geom/LinearRing.cpp b/src/geom/LinearRing.cpp
index df7d3ca..64e8357 100644
--- a/src/geom/LinearRing.cpp
+++ b/src/geom/LinearRing.cpp
@@ -34,13 +34,12 @@ namespace geos {
 namespace geom { // geos::geom
 
 /*public*/
-LinearRing::LinearRing(const LinearRing& lr): Geometry(lr), LineString(lr) {}
+LinearRing::LinearRing(const LinearRing& lr): LineString(lr) {}
 
 /*public*/
 LinearRing::LinearRing(CoordinateSequence* newCoords,
                        const GeometryFactory* newFactory)
     :
-    Geometry(newFactory),
     LineString(newCoords, newFactory)
 {
     validateConstruction();
@@ -50,7 +49,6 @@ LinearRing::LinearRing(CoordinateSequence* newCoords,
 LinearRing::LinearRing(CoordinateSequence::Ptr newCoords,
                        const GeometryFactory* newFactory)
     :
-    Geometry(newFactory),
     LineString(std::move(newCoords), newFactory)
 {
     validateConstruction();
diff --git a/src/geom/MultiLineString.cpp b/src/geom/MultiLineString.cpp
index bc909ed..6eb07d5 100644
--- a/src/geom/MultiLineString.cpp
+++ b/src/geom/MultiLineString.cpp
@@ -43,7 +43,6 @@ namespace geom { // geos::geom
 MultiLineString::MultiLineString(vector<Geometry*>* newLines,
                                  const GeometryFactory* factory)
     :
-    Geometry(factory),
     GeometryCollection(newLines, factory)
 {
 }
diff --git a/src/geom/MultiPoint.cpp b/src/geom/MultiPoint.cpp
index ba6ddb2..ddb3690 100644
--- a/src/geom/MultiPoint.cpp
+++ b/src/geom/MultiPoint.cpp
@@ -34,7 +34,6 @@ namespace geom { // geos::geom
 /*protected*/
 MultiPoint::MultiPoint(vector<Geometry*>* newPoints, const GeometryFactory* factory)
     :
-    Geometry(factory),
     GeometryCollection(newPoints, factory)
 {
 }
diff --git a/src/geom/MultiPolygon.cpp b/src/geom/MultiPolygon.cpp
index cfaa121..777c37e 100644
--- a/src/geom/MultiPolygon.cpp
+++ b/src/geom/MultiPolygon.cpp
@@ -41,8 +41,7 @@ namespace geom { // geos::geom
 
 /*protected*/
 MultiPolygon::MultiPolygon(vector<Geometry*>* newPolys, const GeometryFactory* factory)
-    : Geometry(factory),
-      GeometryCollection(newPolys, factory)
+      : GeometryCollection(newPolys, factory)
 {}
 
 MultiPolygon::~MultiPolygon() {}

commit aff7bcf25a4879d95243c5a60240a4ee0b4a06a6
Author: Daniel Baston <dbaston at gmail.com>
Date:   Thu Jun 20 19:47:50 2019 -0400

    Avoid heap-allocating std::vector in CoordinateArraySequence

diff --git a/include/geos/geom/CoordinateArraySequence.h b/include/geos/geom/CoordinateArraySequence.h
index a1cdaf6..0476ce2 100644
--- a/include/geos/geom/CoordinateArraySequence.h
+++ b/include/geos/geom/CoordinateArraySequence.h
@@ -74,14 +74,14 @@ public:
     bool
     empty() const
     {
-        return vect->empty();
+        return vect.empty();
     }
 
     /// Reset this CoordinateArraySequence to the empty state
     void
     clear()
     {
-        vect->clear();
+        vect.clear();
     }
 
     /// Add a Coordinate to the list
@@ -129,7 +129,7 @@ public:
     void apply_ro(CoordinateFilter* filter) const override;
 
 private:
-    std::vector<Coordinate>* vect;
+    std::vector<Coordinate> vect;
     mutable std::size_t dimension;
 };
 
diff --git a/src/geom/CoordinateArraySequence.cpp b/src/geom/CoordinateArraySequence.cpp
index 32c12b6..d451a35 100644
--- a/src/geom/CoordinateArraySequence.cpp
+++ b/src/geom/CoordinateArraySequence.cpp
@@ -25,30 +25,29 @@
 #include <vector>
 #include <cmath>
 
-using namespace std;
-
 namespace geos {
 namespace geom { // geos::geom
 
 CoordinateArraySequence::CoordinateArraySequence():
-    vect(new vector<Coordinate>()),
     dimension(0)
 {
 }
 
 CoordinateArraySequence::CoordinateArraySequence(size_t n,
         size_t dimension_in):
-    vect(new vector<Coordinate>(n)),
+    vect(n),
     dimension(dimension_in)
 {
 }
 
 CoordinateArraySequence::CoordinateArraySequence(
-    vector<Coordinate>* coords, size_t dimension_in)
-    : vect(coords), dimension(dimension_in)
+    std::vector<Coordinate>* coords, size_t dimension_in)
+    : dimension(dimension_in)
 {
-    if(! vect) {
-        vect = new vector<Coordinate>();
+    std::unique_ptr<std::vector<Coordinate>> coordp(coords);
+
+    if(coordp) {
+        vect = std::move(*coords);
     }
 }
 
@@ -56,7 +55,7 @@ CoordinateArraySequence::CoordinateArraySequence(
     const CoordinateArraySequence& c)
     :
     CoordinateSequence(c),
-    vect(new vector<Coordinate>(*(c.vect))),
+    vect(c.vect),
     dimension(c.getDimension())
 {
 }
@@ -65,11 +64,11 @@ CoordinateArraySequence::CoordinateArraySequence(
     const CoordinateSequence& c)
     :
     CoordinateSequence(c),
-    vect(new vector<Coordinate>(c.size())),
+    vect(c.size()),
     dimension(c.getDimension())
 {
-    for(size_t i = 0, n = vect->size(); i < n; ++i) {
-        (*vect)[i] = c.getAt(i);
+    for(size_t i = 0, n = vect.size(); i < n; ++i) {
+        vect[i] = c.getAt(i);
     }
 }
 
@@ -80,9 +79,9 @@ CoordinateArraySequence::clone() const
 }
 
 void
-CoordinateArraySequence::setPoints(const vector<Coordinate>& v)
+CoordinateArraySequence::setPoints(const std::vector<Coordinate>& v)
 {
-    vect->assign(v.begin(), v.end());
+    vect.assign(v.begin(), v.end());
 }
 
 std::size_t
@@ -92,11 +91,11 @@ CoordinateArraySequence::getDimension() const
         return dimension;
     }
 
-    if(vect->empty()) {
+    if(vect.empty()) {
         return 3;
     }
 
-    if(std::isnan((*vect)[0].z)) {
+    if(std::isnan(vect[0].z)) {
         dimension = 2;
     }
     else {
@@ -107,28 +106,27 @@ CoordinateArraySequence::getDimension() const
 }
 
 void
-CoordinateArraySequence::toVector(vector<Coordinate>& out) const
+CoordinateArraySequence::toVector(std::vector<Coordinate>& out) const
 {
-    // TODO: can this be optimized ?
-    out.insert(out.end(), vect->begin(), vect->end());
+    out.insert(out.end(), vect.begin(), vect.end());
 }
 
 void
 CoordinateArraySequence::add(const Coordinate& c)
 {
-    vect->push_back(c);
+    vect.push_back(c);
 }
 
 void
 CoordinateArraySequence::add(const Coordinate& c, bool allowRepeated)
 {
-    if(!allowRepeated && ! vect->empty()) {
-        const Coordinate& last = vect->back();
+    if(!allowRepeated && ! vect.empty()) {
+        const Coordinate& last = vect.back();
         if(last.equals2D(c)) {
             return;
         }
     }
-    vect->push_back(c);
+    vect.push_back(c);
 }
 
 void
@@ -173,43 +171,40 @@ CoordinateArraySequence::add(size_t i, const Coordinate& coord,
         }
     }
 
-    vect->insert(vect->begin() + i, coord);
+    vect.insert(vect.begin() + i, coord);
 }
 
 size_t
 CoordinateArraySequence::getSize() const
 {
-    return vect->size();
+    return vect.size();
 }
 
 const Coordinate&
 CoordinateArraySequence::getAt(size_t pos) const
 {
-    return (*vect)[pos];
+    return vect[pos];
 }
 
 void
 CoordinateArraySequence::getAt(size_t pos, Coordinate& c) const
 {
-    c = (*vect)[pos];
+    c = vect[pos];
 }
 
 void
 CoordinateArraySequence::setAt(const Coordinate& c, size_t pos)
 {
-    (*vect)[pos] = c;
+    vect[pos] = c;
 }
 
-CoordinateArraySequence::~CoordinateArraySequence()
-{
-    delete vect;
-}
+CoordinateArraySequence::~CoordinateArraySequence() = default;
 
 void
 CoordinateArraySequence::expandEnvelope(Envelope& env) const
 {
-    for(size_t i = 0, n = vect->size(); i < n; ++i) {
-        env.expandToInclude((*vect)[i]);
+    for(const auto& coord : vect) {
+        env.expandToInclude(coord);
     }
 }
 
@@ -218,11 +213,11 @@ CoordinateArraySequence::getOrdinate(size_t index, size_t ordinateIndex) const
 {
     switch(ordinateIndex) {
     case CoordinateSequence::X:
-        return (*vect)[index].x;
+        return vect[index].x;
     case CoordinateSequence::Y:
-        return (*vect)[index].y;
+        return vect[index].y;
     case CoordinateSequence::Z:
-        return (*vect)[index].z;
+        return vect[index].z;
     default:
         return DoubleNotANumber;
     }
@@ -234,13 +229,13 @@ CoordinateArraySequence::setOrdinate(size_t index, size_t ordinateIndex,
 {
     switch(ordinateIndex) {
     case CoordinateSequence::X:
-        (*vect)[index].x = value;
+        vect[index].x = value;
         break;
     case CoordinateSequence::Y:
-        (*vect)[index].y = value;
+        vect[index].y = value;
         break;
     case CoordinateSequence::Z:
-        (*vect)[index].z = value;
+        vect[index].z = value;
         break;
     default: {
         std::stringstream ss;
@@ -254,8 +249,8 @@ CoordinateArraySequence::setOrdinate(size_t index, size_t ordinateIndex,
 void
 CoordinateArraySequence::apply_rw(const CoordinateFilter* filter)
 {
-    for(vector<Coordinate>::iterator i = vect->begin(), e = vect->end(); i != e; ++i) {
-        filter->filter_rw(&(*i));
+    for(auto& coord : vect) {
+        filter->filter_rw(&coord);
     }
     dimension = 0; // re-check (see http://trac.osgeo.org/geos/ticket/435)
 }
@@ -263,8 +258,8 @@ CoordinateArraySequence::apply_rw(const CoordinateFilter* filter)
 void
 CoordinateArraySequence::apply_ro(CoordinateFilter* filter) const
 {
-    for(vector<Coordinate>::const_iterator i = vect->begin(), e = vect->end(); i != e; ++i) {
-        filter->filter_ro(&(*i));
+    for(const auto& coord : vect) {
+        filter->filter_ro(&coord);
     }
 }
 

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

Summary of changes:
 include/geos/geom/CoordinateArraySequence.h |  6 +--
 include/geos/geom/GeometryCollection.h      |  2 +-
 include/geos/geom/LineString.h              |  2 +-
 include/geos/geom/MultiLineString.inl       |  1 -
 include/geos/geom/MultiPoint.h              |  2 +-
 include/geos/geom/MultiPolygon.inl          |  1 -
 include/geos/geom/Point.h                   |  2 +-
 include/geos/geom/Polygon.h                 |  2 +-
 src/geom/CoordinateArraySequence.cpp        | 83 ++++++++++++++---------------
 src/geom/LinearRing.cpp                     |  4 +-
 src/geom/MultiLineString.cpp                |  1 -
 src/geom/MultiPoint.cpp                     |  1 -
 src/geom/MultiPolygon.cpp                   |  3 +-
 13 files changed, 49 insertions(+), 61 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list