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 committed Mar 25, 2021
2 parents 93f45e7 + df7e8af commit e713cd7e6d0b214aaa3026cc566f81b45d38accb
Showing with 7 additions and 5 deletions.
  1. +7 −5 src/core/providers/ogr/qgsogrprovider.cpp
@@ -2273,6 +2273,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;
@@ -2354,10 +2356,11 @@ bool QgsOgrProvider::_setSubsetString( const QString &theSQL, bool updateFeature

mRefreshFeatureCount = updateFeatureCount;

// 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 );

@@ -7123,4 +7126,3 @@ QgsProviderMetadata::ProviderCapabilities QgsOgrProviderMetadata::providerCapabi
return FileBasedUris;
}
///@endcond

0 comments on commit e713cd7

Please sign in to comment.