Skip to content
Permalink
Browse files

Merge pull request #42412 from elpaso/optimization-ogr-avoid-double-l…

…oad-fields-call

Prevent double expensive calls to loadFields in OGR
  • Loading branch information
elpaso authored and github-actions committed Mar 25, 2021
1 parent d70f262 commit 0b045a8d7aeba392390b9c9b1fbbac8bad7c305c
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/core/providers/ogr/qgsogrprovider.cpp
@@ -2214,6 +2214,8 @@ bool QgsOgrProvider::_setSubsetString( const QString &theSQL, bool updateFeature
if ( theSQL == mSubsetString && mFeaturesCounted != QgsVectorDataProvider::Uncounted )
return true;

const bool subsetStringHasChanged { theSQL != mSubsetString };

if ( !theSQL.isEmpty() )
{
QMutex *mutex = nullptr;
@@ -2300,10 +2302,11 @@ bool QgsOgrProvider::_setSubsetString( const QString &theSQL, bool updateFeature
recalculateFeatureCount();
}

// check the validity of the layer
QgsDebugMsgLevel( QStringLiteral( "checking validity" ), 4 );
loadFields();
QgsDebugMsgLevel( QStringLiteral( "Done checking validity" ), 4 );
// check the validity of the layer if subset string has changed
if ( subsetStringHasChanged )
{
loadFields();
}

invalidateCachedExtent( false );

0 comments on commit 0b045a8

Please sign in to comment.