mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
Optimize QgsVectorLayerFeatureIterator a bit
11% speedup when rendering 1 million points from memory provider
This commit is contained in:
parent
ebae48599b
commit
86015ea429
@ -96,6 +96,8 @@ QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator( QgsVectorLayerFeat
|
|||||||
|
|
||||||
prepareExpressions();
|
prepareExpressions();
|
||||||
|
|
||||||
|
mHasVirtualAttributes = !mFetchJoinInfo.isEmpty() || !mExpressionFieldInfo.isEmpty();
|
||||||
|
|
||||||
// by default provider's request is the same
|
// by default provider's request is the same
|
||||||
mProviderRequest = mRequest;
|
mProviderRequest = mRequest;
|
||||||
|
|
||||||
@ -211,9 +213,11 @@ bool QgsVectorLayerFeatureIterator::fetchFeature( QgsFeature& f )
|
|||||||
f.setFields( &mSource->mFields );
|
f.setFields( &mSource->mFields );
|
||||||
|
|
||||||
// update attributes
|
// update attributes
|
||||||
updateChangedAttributes( f );
|
if ( mSource->mHasEditBuffer )
|
||||||
|
updateChangedAttributes( f );
|
||||||
|
|
||||||
addVirtualAttributes( f );
|
if ( mHasVirtualAttributes )
|
||||||
|
addVirtualAttributes( f );
|
||||||
|
|
||||||
// update geometry
|
// update geometry
|
||||||
// TODO[MK]: FilterRect check after updating the geometry
|
// TODO[MK]: FilterRect check after updating the geometry
|
||||||
@ -311,7 +315,8 @@ void QgsVectorLayerFeatureIterator::useAddedFeature( const QgsFeature& src, QgsF
|
|||||||
|
|
||||||
f.setAttributes( src.attributes() );
|
f.setAttributes( src.attributes() );
|
||||||
|
|
||||||
addVirtualAttributes( f );
|
if ( mHasVirtualAttributes )
|
||||||
|
addVirtualAttributes( f );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -351,7 +356,8 @@ bool QgsVectorLayerFeatureIterator::fetchNextChangedAttributeFeature( QgsFeature
|
|||||||
|
|
||||||
updateChangedAttributes( f );
|
updateChangedAttributes( f );
|
||||||
|
|
||||||
addVirtualAttributes( f );
|
if ( mHasVirtualAttributes )
|
||||||
|
addVirtualAttributes( f );
|
||||||
|
|
||||||
if ( mRequest.filterType() == QgsFeatureRequest::FilterExpression )
|
if ( mRequest.filterType() == QgsFeatureRequest::FilterExpression )
|
||||||
{
|
{
|
||||||
@ -404,7 +410,8 @@ void QgsVectorLayerFeatureIterator::useChangedAttributeFeature( QgsFeatureId fid
|
|||||||
QgsFeatureIterator fi = mSource->mProviderFeatureSource->getFeatures( request );
|
QgsFeatureIterator fi = mSource->mProviderFeatureSource->getFeatures( request );
|
||||||
if ( fi.nextFeature( tmp ) )
|
if ( fi.nextFeature( tmp ) )
|
||||||
{
|
{
|
||||||
updateChangedAttributes( tmp );
|
if ( mHasVirtualAttributes )
|
||||||
|
updateChangedAttributes( tmp );
|
||||||
f.setAttributes( tmp.attributes() );
|
f.setAttributes( tmp.attributes() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -732,9 +739,11 @@ bool QgsVectorLayerFeatureIterator::nextFeatureFid( QgsFeature& f )
|
|||||||
QgsFeatureIterator fi = mSource->mProviderFeatureSource->getFeatures( mProviderRequest );
|
QgsFeatureIterator fi = mSource->mProviderFeatureSource->getFeatures( mProviderRequest );
|
||||||
if ( fi.nextFeature( f ) )
|
if ( fi.nextFeature( f ) )
|
||||||
{
|
{
|
||||||
updateChangedAttributes( f );
|
if ( mSource->mHasEditBuffer )
|
||||||
|
updateChangedAttributes( f );
|
||||||
|
|
||||||
addVirtualAttributes( f );
|
if ( mHasVirtualAttributes )
|
||||||
|
addVirtualAttributes( f );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -152,6 +152,8 @@ class CORE_EXPORT QgsVectorLayerFeatureIterator : public QgsAbstractFeatureItera
|
|||||||
|
|
||||||
QMap<int, QgsExpression*> mExpressionFieldInfo;
|
QMap<int, QgsExpression*> mExpressionFieldInfo;
|
||||||
|
|
||||||
|
bool mHasVirtualAttributes;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! optional object to locally simplify edited (changed or added) geometries fetched by this feature iterator
|
//! optional object to locally simplify edited (changed or added) geometries fetched by this feature iterator
|
||||||
QgsAbstractGeometrySimplifier* mEditGeometrySimplifier;
|
QgsAbstractGeometrySimplifier* mEditGeometrySimplifier;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user