Skip to content

Commit cbeb8b2

Browse files
committed
Improve performance
1 parent 1fb88a7 commit cbeb8b2

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/core/qgsvectorlayerjoinbuffer.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ bool QgsVectorLayerJoinBuffer::addFeatures( QgsFeatureList &features, QgsFeature
541541
const QString filter = QgsExpression::createFieldEqualityExpression( info.joinFieldName(), idFieldValue.toString() );
542542

543543
QgsFeatureRequest request;
544+
request.setFlags( QgsFeatureRequest::NoGeometry );
544545
request.setFilterExpression( filter );
545546
request.setLimit( 1 );
546547

@@ -554,15 +555,21 @@ bool QgsVectorLayerJoinBuffer::addFeatures( QgsFeatureList &features, QgsFeature
554555
if ( subsetFields )
555556
{
556557
Q_FOREACH ( const QString &field, *subsetFields )
557-
existingFeature.setAttribute( field, joinFeature.attribute( field ) );
558+
{
559+
QVariant newValue = joinFeature.attribute( field );
560+
int fieldIndex = joinLayer->fields().indexOf( field );
561+
joinLayer->changeAttributeValue( existingFeature.id(), fieldIndex, newValue );
562+
}
558563
}
559564
else
560565
{
561566
Q_FOREACH ( const QgsField &field, joinFeature.fields() )
562-
existingFeature.setAttribute( field.name(), joinFeature.attribute( field.name() ) );
567+
{
568+
QVariant newValue = joinFeature.attribute( field.name() );
569+
int fieldIndex = joinLayer->fields().indexOf( field.name() );
570+
joinLayer->changeAttributeValue( existingFeature.id(), fieldIndex, newValue );
571+
}
563572
}
564-
565-
joinLayer->updateFeature( existingFeature );
566573
}
567574
else
568575
{

0 commit comments

Comments
 (0)