[geos-commits] r2732 - in trunk/source: headers/geos/noding noding

svn_geos at osgeo.org svn_geos at osgeo.org
Thu Nov 19 16:30:01 EST 2009


Author: strk
Date: 2009-11-19 16:30:01 -0500 (Thu, 19 Nov 2009)
New Revision: 2732

Modified:
   trunk/source/headers/geos/noding/MCIndexSegmentSetMutualIntersector.h
   trunk/source/noding/MCIndexSegmentSetMutualIntersector.cpp
Log:
Don't heap-allocate std::vector in MCIndexSegmentSetMutualIntersector


Modified: trunk/source/headers/geos/noding/MCIndexSegmentSetMutualIntersector.h
===================================================================
--- trunk/source/headers/geos/noding/MCIndexSegmentSetMutualIntersector.h	2009-11-19 21:06:16 UTC (rev 2731)
+++ trunk/source/headers/geos/noding/MCIndexSegmentSetMutualIntersector.h	2009-11-19 21:30:01 UTC (rev 2732)
@@ -56,7 +56,7 @@
 
 	~MCIndexSegmentSetMutualIntersector();
 
-	std::vector<index::chain::MonotoneChain *>* getMonotoneChains() 
+	std::vector<index::chain::MonotoneChain *>& getMonotoneChains() 
 	{ 
 		return monoChains; 
 	}
@@ -89,7 +89,8 @@
 
 private:
 
-	std::vector<index::chain::MonotoneChain *> * monoChains;
+	typedef std::vector<index::chain::MonotoneChain *> MonoChains;
+	MonoChains monoChains;
 
 	/*
 	 * The {@link SpatialIndex} used should be something that supports

Modified: trunk/source/noding/MCIndexSegmentSetMutualIntersector.cpp
===================================================================
--- trunk/source/noding/MCIndexSegmentSetMutualIntersector.cpp	2009-11-19 21:06:16 UTC (rev 2731)
+++ trunk/source/noding/MCIndexSegmentSetMutualIntersector.cpp	2009-11-19 21:30:01 UTC (rev 2732)
@@ -54,9 +54,9 @@
 {
     MCIndexSegmentSetMutualIntersector::SegmentOverlapAction overlapAction( *segInt);
 
-    for (std::size_t i = 0, ni = monoChains->size(); i < ni; i++)
+    for (MonoChains::size_type i = 0, ni = monoChains.size(); i < ni; ++i)
     {
-        MonotoneChain * queryChain = (MonotoneChain *)((*monoChains)[i]);
+        MonotoneChain * queryChain = (MonotoneChain *)monoChains[i];
 
         std::vector<void*> overlapChains;
         index->query( &(queryChain->getEnvelope()), overlapChains);
@@ -76,16 +76,16 @@
 void 
 MCIndexSegmentSetMutualIntersector::addToMonoChains(SegmentString* segStr)
 {
-    std::vector<MonotoneChain*>* segChains = 0; 
-    segChains = MonotoneChainBuilder::getChains(segStr->getCoordinates(), segStr);
+    MonoChains* segChains = 
+    	MonotoneChainBuilder::getChains(segStr->getCoordinates(), segStr);
 
     chainStore.push_back(segChains);
 
-    for (std::size_t i = 0, ni = segChains->size(); i < ni; i++)
+    for (MonoChains::size_type i = 0, ni = segChains->size(); i < ni; i++)
     {
         MonotoneChain* mc = (*segChains)[i];
         mc->setId( processCounter++ );
-        monoChains->push_back(mc);
+        monoChains.push_back(mc);
     }
 }
 
@@ -94,7 +94,7 @@
 //
 
 MCIndexSegmentSetMutualIntersector::MCIndexSegmentSetMutualIntersector() 
-:	monoChains( new std::vector<index::chain::MonotoneChain *>()),
+:	monoChains(),
 index(new geos::index::strtree::STRtree()),
 indexCounter(0),
 processCounter(0),
@@ -105,7 +105,6 @@
 MCIndexSegmentSetMutualIntersector::~MCIndexSegmentSetMutualIntersector() 
 {
     delete index;
-    delete monoChains;
 
     chainstore_mm_type::iterator end = chainStore.end();
     for (chainstore_mm_type::iterator it = chainStore.begin(); it != end; ++it)
@@ -138,7 +137,7 @@
 {
     processCounter = indexCounter + 1;
     nOverlaps = 0;
-    monoChains->clear();
+    monoChains.clear();
 
     for (std::size_t i = 0, n = segStrings->size(); i < n; i++)
     {



More information about the geos-commits mailing list