Skip to content

Commit

Permalink
Improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Aug 28, 2017
1 parent 1fb88a7 commit cbeb8b2
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/core/qgsvectorlayerjoinbuffer.cpp
Expand Up @@ -541,6 +541,7 @@ bool QgsVectorLayerJoinBuffer::addFeatures( QgsFeatureList &features, QgsFeature
const QString filter = QgsExpression::createFieldEqualityExpression( info.joinFieldName(), idFieldValue.toString() );

QgsFeatureRequest request;
request.setFlags( QgsFeatureRequest::NoGeometry );
request.setFilterExpression( filter );
request.setLimit( 1 );

Expand All @@ -554,15 +555,21 @@ bool QgsVectorLayerJoinBuffer::addFeatures( QgsFeatureList &features, QgsFeature
if ( subsetFields )
{
Q_FOREACH ( const QString &field, *subsetFields )
existingFeature.setAttribute( field, joinFeature.attribute( field ) );
{
QVariant newValue = joinFeature.attribute( field );
int fieldIndex = joinLayer->fields().indexOf( field );
joinLayer->changeAttributeValue( existingFeature.id(), fieldIndex, newValue );
}
}
else
{
Q_FOREACH ( const QgsField &field, joinFeature.fields() )
existingFeature.setAttribute( field.name(), joinFeature.attribute( field.name() ) );
{
QVariant newValue = joinFeature.attribute( field.name() );
int fieldIndex = joinLayer->fields().indexOf( field.name() );
joinLayer->changeAttributeValue( existingFeature.id(), fieldIndex, newValue );
}
}

joinLayer->updateFeature( existingFeature );
}
else
{
Expand Down

0 comments on commit cbeb8b2

Please sign in to comment.