Skip to content

Commit

Permalink
Use optimised deleteFeatures method when we can
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson authored and github-actions[bot] committed Nov 18, 2022
1 parent 93084f9 commit 519553c
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/core/vector/qgsvectorlayer.cpp
Expand Up @@ -3438,9 +3438,24 @@ bool QgsVectorLayer::deleteFeature( QgsFeatureId fid, QgsVectorLayer::DeleteCont
bool QgsVectorLayer::deleteFeatures( const QgsFeatureIds &fids, QgsVectorLayer::DeleteContext *context )
{
bool res = true;
const auto constFids = fids;
for ( QgsFeatureId fid : constFids )
res = deleteFeatureCascade( fid, context ) && res;

if ( ( context && context->cascade ) || mJoinBuffer->containsJoins() )
{
// should ideally be "deleteFeaturesCascade" for performance!
for ( QgsFeatureId fid : fids )
res = deleteFeatureCascade( fid, context ) && res;
}
else
{
if ( mEditBuffer )
{
res = mEditBuffer->deleteFeatures( fids );
}
else
{
res = false;
}
}

if ( res )
{
Expand Down

0 comments on commit 519553c

Please sign in to comment.