Skip to content
Permalink
Browse files

Speed up inserting features into memory layers by ~65%

By avoiding an unnecessary map lookup
  • Loading branch information
nyalldawson committed Nov 1, 2016
1 parent d3c7a04 commit b679cbe0918915030b8991272eab32240070038a
Showing with 4 additions and 5 deletions.
  1. +4 −5 src/providers/memory/qgsmemoryprovider.cpp
@@ -301,15 +301,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 b679cbe

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