Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Avoid two geometry copies in postgresprovider. Just pass geometry poi…
…nters instead

git-svn-id: http://svn.osgeo.org/qgis/trunk@7270 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Oct 13, 2007
1 parent e47e592 commit fe4278d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/core/qgsfeature.cpp
Expand Up @@ -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
*/
Expand Down
3 changes: 3 additions & 0 deletions src/core/qgsfeature.h
Expand Up @@ -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
*/
Expand Down
12 changes: 10 additions & 2 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -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

Expand All @@ -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();

}
Expand Down

0 comments on commit fe4278d

Please sign in to comment.