[geos-commits] [SCM] GEOS branch master updated. 8eaa475d27ab262489c3b88ced922f30d4dc136f
git at osgeo.org
git at osgeo.org
Wed Sep 4 18:41:39 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 8eaa475d27ab262489c3b88ced922f30d4dc136f (commit)
from 53f842fb79cdb3f44291bfdbe05388dbbb99a6f5 (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 8eaa475d27ab262489c3b88ced922f30d4dc136f
Author: Daniel Baston <dbaston at gmail.com>
Date: Wed Sep 4 21:35:10 2019 -0400
Use unique_ptr in geomgraph::Edge
Also reorder members to reduce class size by 8 bytes
diff --git a/benchmarks/ClassSizes.cpp b/benchmarks/ClassSizes.cpp
index 1e45a7f..a8b5e63 100644
--- a/benchmarks/ClassSizes.cpp
+++ b/benchmarks/ClassSizes.cpp
@@ -28,7 +28,9 @@
#include <geos/geom/MultiPoint.h>
#include <geos/geom/MultiLineString.h>
#include <geos/geom/MultiPolygon.h>
+#include <geos/geomgraph/Depth.h>
#include <geos/geomgraph/DirectedEdge.h>
+#include <geos/geomgraph/Edge.h>
#include <geos/geomgraph/EdgeEnd.h>
#include <geos/geomgraph/PlanarGraph.h>
#include <geos/noding/NodedSegmentString.h>
@@ -45,9 +47,11 @@ using namespace geos;
int
main()
{
- check(geomgraph::PlanarGraph);
- check(geomgraph::EdgeEnd);
+ check(geomgraph::Depth);
check(geomgraph::DirectedEdge);
+ check(geomgraph::Edge);
+ check(geomgraph::EdgeEnd);
+ check(geomgraph::PlanarGraph);
check(noding::NodedSegmentString);
check(geom::Geometry);
check(geom::Point);
diff --git a/include/geos/geomgraph/Edge.h b/include/geos/geomgraph/Edge.h
index e91a9ba..b6d6be9 100644
--- a/include/geos/geomgraph/Edge.h
+++ b/include/geos/geomgraph/Edge.h
@@ -71,17 +71,17 @@ private:
std::string name;
/// Lazily-created, owned by Edge.
- index::MonotoneChainEdge* mce;
+ std::unique_ptr<index::MonotoneChainEdge> mce;
/// Lazily-created, owned by Edge.
- geom::Envelope* env;
-
- bool isIsolatedVar;
+ std::unique_ptr<geom::Envelope> env;
Depth depth;
int depthDelta; // the change in area depth from the R to L side of this edge
+ bool isIsolatedVar;
+
public:
void
@@ -97,7 +97,7 @@ public:
static void updateIM(const Label& lbl, geom::IntersectionMatrix& im);
/// Externally-set, owned by Edge. FIXME: refuse ownership
- geom::CoordinateSequence* pts;
+ std::unique_ptr<geom::CoordinateSequence> pts;
EdgeIntersectionList eiList;
@@ -127,7 +127,7 @@ public:
getCoordinates() const
{
testInvariant();
- return pts;
+ return pts.get();
}
virtual const geom::Coordinate&
diff --git a/src/geomgraph/Edge.cpp b/src/geomgraph/Edge.cpp
index 5787260..1aa22e2 100644
--- a/src/geomgraph/Edge.cpp
+++ b/src/geomgraph/Edge.cpp
@@ -35,6 +35,7 @@
#include <geos/geom/CoordinateSequence.h>
#include <geos/geom/CoordinateArraySequence.h> // FIXME: shouldn't use
#include <geos/geom/Coordinate.h>
+#include <geos/util.h>
//#define GEOS_DEBUG_INTERSECT 0
#ifndef GEOS_DEBUG
@@ -77,13 +78,7 @@ Edge::updateIM(const Label& lbl, IntersectionMatrix& im)
}
/*public*/
-Edge::~Edge()
-{
- //cerr<<"["<<this<<"] ~Edge()"<<endl;
- delete mce;
- delete pts;
- delete env;
-}
+Edge::~Edge() = default;
/*public*/
Edge::Edge(CoordinateSequence* newPts, const Label& newLabel)
@@ -91,9 +86,9 @@ Edge::Edge(CoordinateSequence* newPts, const Label& newLabel)
GraphComponent(newLabel),
mce(nullptr),
env(nullptr),
- isIsolatedVar(true),
depth(),
depthDelta(0),
+ isIsolatedVar(true),
pts(newPts),
eiList(this)
{
@@ -106,9 +101,9 @@ Edge::Edge(CoordinateSequence* newPts)
GraphComponent(),
mce(nullptr),
env(nullptr),
- isIsolatedVar(true),
depth(),
depthDelta(0),
+ isIsolatedVar(true),
pts(newPts),
eiList(this)
{
@@ -121,9 +116,9 @@ Edge::getMonotoneChainEdge()
{
testInvariant();
if(mce == nullptr) {
- mce = new MonotoneChainEdge(this);
+ mce = detail::make_unique<MonotoneChainEdge>(this);
}
- return mce;
+ return mce.get();
}
@@ -309,14 +304,14 @@ Edge::getEnvelope()
{
// compute envelope lazily
if(env == nullptr) {
- env = new Envelope();
+ env = detail::make_unique<Envelope>();
auto npts = getNumPoints();
for(size_t i = 0; i < npts; ++i) {
env->expandToInclude(pts->getAt(i));
}
}
testInvariant();
- return env;
+ return env.get();
}
std::ostream&
-----------------------------------------------------------------------
Summary of changes:
benchmarks/ClassSizes.cpp | 8 ++++++--
include/geos/geomgraph/Edge.h | 12 ++++++------
src/geomgraph/Edge.cpp | 21 ++++++++-------------
3 files changed, 20 insertions(+), 21 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list