[geos-commits] r2677 - trunk/source/geom
svn_geos at osgeo.org
svn_geos at osgeo.org
Sat Oct 17 08:02:56 EDT 2009
Author: strk
Date: 2009-10-17 08:02:56 -0400 (Sat, 17 Oct 2009)
New Revision: 2677
Modified:
trunk/source/geom/Polygon.cpp
Log:
Don't allocate too much space for polygon points vector. Fixes bug #294.
Modified: trunk/source/geom/Polygon.cpp
===================================================================
--- trunk/source/geom/Polygon.cpp 2009-10-16 15:27:16 UTC (rev 2676)
+++ trunk/source/geom/Polygon.cpp 2009-10-17 12:02:56 UTC (rev 2677)
@@ -117,20 +117,28 @@
npts=shellCoords->getSize();
/*
- * reserve space in the vector as if all holes have the same
- * amount of points. Holes usually have less, so this should
- * be a good compromise
+ * reserve space in the vector for all the polygon points
*/
- cl->reserve((nholes+1)*npts);
+ cl->reserve(getNumPoints());
- for (j=0; j<npts; ++j) cl->push_back(shellCoords->getAt(j));
+ for (j=0; j<npts; ++j)
+ {
+ // This can be optimized by having CoordinateSequence
+ // expose a method to push all coords to a vector
+ cl->push_back(shellCoords->getAt(j));
+ }
for (i=0; i<nholes; ++i)
{
// Add hole points
const CoordinateSequence* childCoords=((LinearRing *)(*holes)[i])->getCoordinatesRO();
npts=childCoords->getSize();
- for (j=0; j<npts; ++j) cl->push_back(childCoords->getAt(j));
+ for (j=0; j<npts; ++j)
+ {
+ // This can be optimized by having CoordinateSequence
+ // expose a method to push all coords to a vector
+ cl->push_back(childCoords->getAt(j));
+ }
}
return getFactory()->getCoordinateSequenceFactory()->create(cl);
More information about the geos-commits
mailing list