[geos-commits] r2680 - trunk/source/geom

svn_geos at osgeo.org svn_geos at osgeo.org
Sat Oct 17 09:40:26 EDT 2009


Author: strk
Date: 2009-10-17 09:40:25 -0400 (Sat, 17 Oct 2009)
New Revision: 2680

Modified:
   trunk/source/geom/CoordinateArraySequence.cpp
Log:
Drop pointless asserts. We'd abort anyway if vector is null. For the out-of-range case the GNU c++ lib helps debugging with an environment variable 


Modified: trunk/source/geom/CoordinateArraySequence.cpp
===================================================================
--- trunk/source/geom/CoordinateArraySequence.cpp	2009-10-17 13:04:35 UTC (rev 2679)
+++ trunk/source/geom/CoordinateArraySequence.cpp	2009-10-17 13:40:25 UTC (rev 2680)
@@ -61,21 +61,18 @@
 void
 CoordinateArraySequence::setPoints(const vector<Coordinate> &v)
 {
-    assert(0 != vect);
 	vect->assign(v.begin(), v.end());
 }
 
 const vector<Coordinate>*
 CoordinateArraySequence::toVector() const
 {
-    assert(0 != vect);
 	return vect; //new vector<Coordinate>(vect->begin(),vect->end());
 }
 
 void
 CoordinateArraySequence::toVector(vector<Coordinate>& out) const
 {
-	assert(0 != vect);
 	// TODO: can this be optimized ?
 	out.insert(out.end(), vect->begin(), vect->end());
 }
@@ -83,21 +80,18 @@
 bool
 CoordinateArraySequence::isEmpty() const
 {
-    assert(0 != vect);
 	return vect->empty();
 }
 
 void
 CoordinateArraySequence::add(const Coordinate& c)
 {
-    assert(0 != vect);
 	vect->push_back(c);
 }
 
 void
 CoordinateArraySequence::add(const Coordinate& c, bool allowRepeated)
 {
-    assert(0 != vect);
 	if (!allowRepeated && ! vect->empty() )
 	{
 		const Coordinate& last=vect->back();
@@ -138,32 +132,24 @@
 const Coordinate &
 CoordinateArraySequence::getAt(size_t pos) const
 {
-    assert(0 != vect);
-	assert(pos < vect->size());
 	return (*vect)[pos];
 }
 
 void
 CoordinateArraySequence::getAt(size_t pos, Coordinate &c) const
 {
-    assert(0 != vect);
-	assert(pos<vect->size());
 	c=(*vect)[pos];
 }
 
 void
 CoordinateArraySequence::setAt(const Coordinate& c, size_t pos)
 {
-    assert(0 != vect);
-	assert(pos<vect->size());
 	(*vect)[pos]=c;
 }
 
 void
 CoordinateArraySequence::deleteAt(size_t pos)
 {
-    assert(0 != vect);
-	assert(pos<vect->size());
 	vect->erase(vect->begin()+pos);
 }
 
@@ -193,17 +179,13 @@
 void
 CoordinateArraySequence::expandEnvelope(Envelope &env) const
 {
-    assert(0 != vect);
-	size_t size = vect->size();
-	for (size_t i=0; i<size; i++) env.expandToInclude((*vect)[i]);
+	for (size_t i=0, n=vect->size(); i<n; ++i)
+		env.expandToInclude((*vect)[i]);
 }
 
 double
 CoordinateArraySequence::getOrdinate(size_t index, size_t ordinateIndex) const
 {
-    assert(0 != vect);
-	assert(index<vect->size());
-
 	switch (ordinateIndex)
 	{
 		case CoordinateSequence::X:
@@ -221,14 +203,6 @@
 CoordinateArraySequence::setOrdinate(size_t index, size_t ordinateIndex,
 	double value)
 {
-
-    assert(0 != vect);
-	assert(index<vect->size());
-
-    assert(ordinateIndex == CoordinateSequence::X
-           || ordinateIndex == CoordinateSequence::Y
-           || ordinateIndex == CoordinateSequence::Z);
-
 	switch (ordinateIndex)
 	{
 		case CoordinateSequence::X:
@@ -241,6 +215,7 @@
 			(*vect)[index].z = value;
 			break;
 		default:
+			assert(0);
 			break;
 	}
 }
@@ -248,7 +223,6 @@
 void
 CoordinateArraySequence::apply_rw(const CoordinateFilter *filter)
 {
-    assert(0 != vect);
 	for (vector<Coordinate>::iterator i=vect->begin(), e=vect->end(); i!=e; ++i)
 	{
 		filter->filter_rw(&(*i));
@@ -258,7 +232,6 @@
 void
 CoordinateArraySequence::apply_ro(CoordinateFilter *filter) const
 {
-    assert(0 != vect);
 	for (vector<Coordinate>::const_iterator i=vect->begin(), e=vect->end(); i!=e; ++i)
 	{
 		filter->filter_ro(&(*i));
@@ -268,7 +241,6 @@
 CoordinateSequence&
 CoordinateArraySequence::removeRepeatedPoints()
 {
-    assert(0 != vect);
 	// We use == operator, which is 2D only
 	vector<Coordinate>::iterator new_end = \
 		std::unique(vect->begin(), vect->end());



More information about the geos-commits mailing list