From c5f65359d8975dd03f180e8287c701933713f6ae Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 27 Nov 2017 07:55:05 +1000 Subject: [PATCH] Cache field lookup when evaluating field-based property values --- src/core/qgsproperty.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/core/qgsproperty.cpp b/src/core/qgsproperty.cpp index df1bd5e35c8..936e3147549 100644 --- a/src/core/qgsproperty.cpp +++ b/src/core/qgsproperty.cpp @@ -448,14 +448,13 @@ QVariant QgsProperty::propertyValue( const QgsExpressionContext &context, const *ok = true; return f.attribute( d->cachedFieldIdx ); } - - int fieldIdx = f.fieldNameIndex( d->fieldName ); - if ( fieldIdx < 0 ) + prepare( context ); + if ( d->cachedFieldIdx < 0 ) return defaultValue; if ( ok ) *ok = true; - return f.attribute( fieldIdx ); + return f.attribute( d->cachedFieldIdx ); } case ExpressionBasedProperty: