Skip to content

Commit

Permalink
Speed up inserting features into memory layers by ~65%
Browse files Browse the repository at this point in the history
By avoiding an unnecessary map lookup

(cherry-picked from b679cbe)
  • Loading branch information
nyalldawson committed Nov 23, 2016
1 parent cfeeb3f commit d8f9d2e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/providers/memory/qgsmemoryprovider.cpp
Expand Up @@ -331,15 +331,14 @@ bool QgsMemoryProvider::addFeatures( QgsFeatureList & flist )
// TODO: sanity checks of fields and geometries
for ( QgsFeatureList::iterator it = flist.begin(); it != flist.end(); ++it )
{
mFeatures[mNextFeatureId] = *it;
QgsFeature& newfeat = mFeatures[mNextFeatureId];
newfeat.setFeatureId( mNextFeatureId );
newfeat.setValid( true );
it->setFeatureId( mNextFeatureId );
it->setValid( true );

mFeatures.insert( mNextFeatureId, *it );

// update spatial index
if ( mSpatialIndex )
mSpatialIndex->insertFeature( newfeat );
mSpatialIndex->insertFeature( *it );

mNextFeatureId++;
}
Expand Down

0 comments on commit d8f9d2e

Please sign in to comment.