Skip to content
Permalink
Browse files

Avoid two geometry copies in postgresprovider. Just pass geometry poi…

…nters instead

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7270 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Oct 13, 2007
1 parent e256c1c commit 3cc57040d5c9673a0ababe4205ab1e87de7fa6e1
Showing with 18 additions and 2 deletions.
  1. +5 −0 src/core/qgsfeature.cpp
  2. +3 −0 src/core/qgsfeature.h
  3. +10 −2 src/providers/postgres/qgspostgresprovider.cpp
@@ -171,6 +171,11 @@ const QgsAttributeMap& QgsFeature::attributeMap() const
return mAttributes;
}

void QgsFeature::setAttributeMap(const QgsAttributeMap& attributeMap)
{
mAttributes = attributeMap;
}

/**
* Add an attribute to the map
*/
@@ -101,6 +101,9 @@ class CORE_EXPORT QgsFeature {
*/
const QgsAttributeMap& attributeMap() const;

/**Sets all the attributes in one go*/
void setAttributeMap(const QgsAttributeMap& attributeMap);

/**
* Add an attribute to the map
*/
@@ -476,7 +476,11 @@ bool QgsPostgresProvider::getNextFeature(QgsFeature& feature)
}
}

mFeatureQueue.push(feature);
//don't copy the geometry. Just pass a pointer instead
mFeatureQueue.push(QgsFeature());
mFeatureQueue.back().setGeometry(feature.geometryAndOwnership());
mFeatureQueue.back().setFeatureId(feature.featureId());
mFeatureQueue.back().setAttributeMap(feature.attributeMap());

} // for each row in queue

@@ -490,7 +494,11 @@ bool QgsPostgresProvider::getNextFeature(QgsFeature& feature)
} // if new queue is required

// Now return the next feature from the queue
feature = mFeatureQueue.front();
//don't copy the geometry. Just pass a pointer instead
feature.setGeometry(mFeatureQueue.front().geometryAndOwnership());
feature.setFeatureId(mFeatureQueue.front().featureId());
feature.setAttributeMap(mFeatureQueue.front().attributeMap());

mFeatureQueue.pop();

}

0 comments on commit 3cc5704

Please sign in to comment.
You can’t perform that action at this time.