[geos-commits] r3076 - in trunk: include/geos/operation/polygonize src/operation/polygonize

svn_geos at osgeo.org svn_geos at osgeo.org
Thu Jul 1 16:03:49 EDT 2010


Author: strk
Date: 2010-07-01 20:03:49 +0000 (Thu, 01 Jul 2010)
New Revision: 3076

Modified:
   trunk/include/geos/operation/polygonize/EdgeRing.h
   trunk/src/operation/polygonize/EdgeRing.cpp
Log:
Drop useless heap-allocation in Polygonize op


Modified: trunk/include/geos/operation/polygonize/EdgeRing.h
===================================================================
--- trunk/include/geos/operation/polygonize/EdgeRing.h	2010-06-24 14:40:01 UTC (rev 3075)
+++ trunk/include/geos/operation/polygonize/EdgeRing.h	2010-07-01 20:03:49 UTC (rev 3076)
@@ -53,13 +53,17 @@
 class GEOS_DLL EdgeRing {
 private:
 	const geom::GeometryFactory *factory; 
-	std::vector<const planargraph::DirectedEdge*> *deList;
 
+	typedef std::vector<const planargraph::DirectedEdge*> DeList;
+	DeList deList;
+
 	// cache the following data for efficiency
 	geom::LinearRing *ring;
 	geom::CoordinateSequence *ringPts;
-	std::vector<geom::Geometry*> *holes;
 
+	typedef std::vector<geom::Geometry*> GeomVect;
+	GeomVect *holes;
+
 	/** \brief
 	 * Computes the list of coordinates which are contained in this ring.
 	 * The coordinatea are computed once only and cached.

Modified: trunk/src/operation/polygonize/EdgeRing.cpp
===================================================================
--- trunk/src/operation/polygonize/EdgeRing.cpp	2010-06-24 14:40:01 UTC (rev 3075)
+++ trunk/src/operation/polygonize/EdgeRing.cpp	2010-07-01 20:03:49 UTC (rev 3076)
@@ -120,7 +120,6 @@
 	cerr<<"["<<this<<"] EdgeRing(factory)"<<endl;
 #endif // DEBUG_ALLOC
 
-	deList=new vector<const DirectedEdge*>();
 	// cache the following data for efficiency
 	ring=NULL;
 	ringPts=NULL;
@@ -133,10 +132,10 @@
 #ifdef DEBUG_ALLOC
 	cerr<<"["<<this<<"] ~EdgeRing()"<<endl;
 #endif // DEBUG_ALLOC
-	delete deList;
 	if ( holes )
 	{
-		for (int i=0; i<(int)holes->size(); i++) delete (*holes)[i];
+		for (GeomVect::size_type i=0, e=holes->size(); i<e; ++i)
+			delete (*holes)[i];
 		delete holes;
 	}
 	delete ring;
@@ -146,7 +145,7 @@
 /*public*/
 void
 EdgeRing::add(const DirectedEdge *de){
-	deList->push_back(de);
+	deList.push_back(de);
 }
 
 /*public*/
@@ -162,7 +161,7 @@
 {
 	if (holes==NULL)
 		holes=new vector<Geometry*>();
-	holes->push_back((Geometry *)hole);
+	holes->push_back(hole);
 }
 
 /*public*/
@@ -190,8 +189,8 @@
 	if (ringPts==NULL)
 	{
 		ringPts=factory->getCoordinateSequenceFactory()->create(NULL);
-		for (int i=0;i<(int)deList->size();i++) {
-			const DirectedEdge *de=(*deList)[i];
+		for (DeList::size_type i=0, e=deList.size(); i<e; ++i) {
+			const DirectedEdge *de=deList[i];
 			assert(dynamic_cast<PolygonizeEdge*>(de->getEdge()));
 			PolygonizeEdge *edge=static_cast<PolygonizeEdge*>(de->getEdge());
 			addEdge(edge->getLine()->getCoordinatesRO(),



More information about the geos-commits mailing list