Skip to content
Permalink
Browse files

Speed up inserting features into memory layers by ~65%

By avoiding an unnecessary map lookup

(cherry-picked from b679cbe)
  • Loading branch information
nyalldawson committed Nov 23, 2016
1 parent cfeeb3f commit d8f9d2e6ec6f10e733ec1a507e036051b22017b9
Showing with 4 additions and 5 deletions.
  1. +4 −5 src/providers/memory/qgsmemoryprovider.cpp
@@ -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++;
}

0 comments on commit d8f9d2e

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