[prev in list] [next in list] [prev in thread] [next in thread]
List: geos-commits
Subject: [geos-commits] r2734 - trunk/source/geom
From: svn_geos () osgeo ! org
Date: 2009-11-23 18:06:38
Message-ID: 20091123180638.C0B65E0154A () lists ! osgeo ! org
[Download RAW message or body]
Author: strk
Date: 2009-11-23 13:06:37 -0500 (Mon, 23 Nov 2009)
New Revision: 2734
Modified:
trunk/source/geom/Geometry.cpp
Log:
Avoid reallocations in Union short-circuit
Modified: trunk/source/geom/Geometry.cpp
===================================================================
--- trunk/source/geom/Geometry.cpp 2009-11-20 19:58:33 UTC (rev 2733)
+++ trunk/source/geom/Geometry.cpp 2009-11-23 18:06:37 UTC (rev 2734)
@@ -563,13 +563,18 @@
{
//cerr<<"SHORTCIRCUITED-UNION engaged"<<endl;
const GeometryCollection *coll;
- size_t ngeoms, i;
+
+ size_t ngeomsThis = getNumGeometries();
+ size_t ngeomsOther = other->getNumGeometries();
+
+ // Allocated for ownership transfer
vector<Geometry *> *v = new vector<Geometry *>();
+ v->reserve(ngeomsThis+ngeomsOther);
+
if ( NULL != (coll = dynamic_cast<const GeometryCollection *>(this)) )
{
- ngeoms = coll->getNumGeometries();
- for (i=0; i<ngeoms; i++)
+ for (size_t i=0; i<ngeomsThis; ++i)
v->push_back(coll->getGeometryN(i)->clone());
} else {
v->push_back(this->clone());
@@ -577,8 +582,7 @@
if ( NULL != (coll = dynamic_cast<const GeometryCollection *>(other)) )
{
- ngeoms = coll->getNumGeometries();
- for (i=0; i<ngeoms; i++)
+ for (size_t i=0; i<ngeomsOther; ++i)
v->push_back(coll->getGeometryN(i)->clone());
} else {
v->push_back(other->clone());
_______________________________________________
geos-commits mailing list
geos-commits@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/geos-commits
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic