Skip to content

Commit

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

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7270 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Oct 13, 2007
1 parent e256c1c commit 3cc5704
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; return mAttributes;
} }


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

/** /**
* Add an attribute to the map * 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; const QgsAttributeMap& attributeMap() const;


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

/** /**
* Add an attribute to the map * 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 } // for each row in queue


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


// Now return the next feature from the queue // 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(); mFeatureQueue.pop();


} }
Expand Down

0 comments on commit 3cc5704

Please sign in to comment.