forked from qt-creator/qt-creator
QmlDesigner: Optimize method by using constinit QString for null return value
- Introduced constinit QString null to replace temporary QString object. - Updated return type to const QString& for better performance and consistency. - Ensured method returns null when no valid binding property is found. Change-Id: Ib74d45237d9396cca72d15bd550b6fb376da84cd Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -16,7 +16,7 @@ class QMLDESIGNERCORE_EXPORT BindingProperty final : public QmlDesigner::Abstrac
|
||||
|
||||
public:
|
||||
void setExpression(const QString &expression);
|
||||
QString expression() const;
|
||||
const QString &expression() const;
|
||||
|
||||
BindingProperty();
|
||||
BindingProperty(const BindingProperty &property, AbstractView *view);
|
||||
|
@@ -56,14 +56,16 @@ void BindingProperty::setExpression(const QString &expression)
|
||||
privateModel()->setBindingProperty(internalNodeSharedPointer(), name(), expression);
|
||||
}
|
||||
|
||||
QString BindingProperty::expression() const
|
||||
const constinit QString null;
|
||||
|
||||
const QString &BindingProperty::expression() const
|
||||
{
|
||||
if (isValid()) {
|
||||
if (auto property = internalNode()->bindingProperty(name()))
|
||||
return property->expression();
|
||||
}
|
||||
|
||||
return QString();
|
||||
return null;
|
||||
}
|
||||
|
||||
ModelNode BindingProperty::resolveBinding(const QString &binding, ModelNode currentNode) const
|
||||
|
@@ -17,7 +17,7 @@ bool InternalBindingProperty::isValid() const
|
||||
return InternalProperty::isValid() && isBindingProperty();
|
||||
}
|
||||
|
||||
QString InternalBindingProperty::expression() const
|
||||
const QString &InternalBindingProperty::expression() const
|
||||
{
|
||||
return m_expression;
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ public:
|
||||
|
||||
bool isValid() const override;
|
||||
|
||||
QString expression() const;
|
||||
const QString &expression() const;
|
||||
void setExpression(const QString &expression);
|
||||
|
||||
void setDynamicExpression(const TypeName &type, const QString &expression);
|
||||
|
Reference in New Issue
Block a user