aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
diff options
context:
space:
mode:
authorThomas Hartmann <thomas.hartmann@qt.io>2018-01-13 18:49:39 +0100
committerThomas Hartmann <thomas.hartmann@qt.io>2018-01-23 10:14:12 +0000
commita7515d25a971aeaf5c54cc9a52a325e05a7c6e98 (patch)
tree02dfeac35705e4b0c727a7fe05830de1fcdf0178 /src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
parent92d32c3a2618719383d4f8678bfd4f5ee041a198 (diff)
QmlDesigner: Avoid detachs
The non const overloads of first() and last() do detach if the reference count is higher than 1. Therefore we use constFirst() and constLast() instead. Change-Id: I737cfc428f1c21f16185b9b51175e181c0ec7068 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Diffstat (limited to 'src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp')
-rw-r--r--src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
index f5bb5d1ba6..46801cf0e0 100644
--- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
+++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
@@ -709,7 +709,7 @@ NodeMetaInfoPrivate::NodeMetaInfoPrivate(Model *model, TypeName type, int maj, i
} else {
m_isFileComponent = true;
const Imports *imports = context()->imports(document());
- ImportInfo importInfo = imports->info(lookupNameComponent().last(), context().data());
+ ImportInfo importInfo = imports->info(lookupNameComponent().constLast(), context().data());
if (importInfo.isValid() && importInfo.type() == ImportType::Library) {
m_majorVersion = importInfo.version().majorVersion();
m_minorVersion = importInfo.version().minorVersion();
@@ -729,7 +729,7 @@ const CppComponentValue *NodeMetaInfoPrivate::getCppComponentValue() const
const QList<TypeName> nameComponents = m_qualfiedTypeName.split('.');
if (nameComponents.size() < 2)
return 0;
- const TypeName type = nameComponents.last();
+ const TypeName &type = nameComponents.constLast();
TypeName module;
for (int i = 0; i < nameComponents.size() - 1; ++i) {
@@ -821,8 +821,8 @@ bool NodeMetaInfoPrivate::isPropertyWritable(const PropertyName &propertyName) c
if (propertyName.contains('.')) {
const PropertyNameList parts = propertyName.split('.');
- const PropertyName objectName = parts.first();
- const PropertyName rawPropertyName = parts.last();
+ const PropertyName &objectName = parts.constFirst();
+ const PropertyName &rawPropertyName = parts.constLast();
const TypeName objectType = propertyType(objectName);
if (isValueType(objectType))
@@ -854,8 +854,8 @@ bool NodeMetaInfoPrivate::isPropertyList(const PropertyName &propertyName) const
if (propertyName.contains('.')) {
const PropertyNameList parts = propertyName.split('.');
- const PropertyName objectName = parts.first();
- const PropertyName rawPropertyName = parts.last();
+ const PropertyName &objectName = parts.constFirst();
+ const PropertyName &rawPropertyName = parts.constLast();
const TypeName objectType = propertyType(objectName);
if (isValueType(objectType))
@@ -883,8 +883,8 @@ bool NodeMetaInfoPrivate::isPropertyPointer(const PropertyName &propertyName) co
if (propertyName.contains('.')) {
const PropertyNameList parts = propertyName.split('.');
- const PropertyName objectName = parts.first();
- const PropertyName rawPropertyName = parts.last();
+ const PropertyName &objectName = parts.constFirst();
+ const PropertyName &rawPropertyName = parts.constLast();
const TypeName objectType = propertyType(objectName);
if (isValueType(objectType))
@@ -915,8 +915,8 @@ bool NodeMetaInfoPrivate::isPropertyEnum(const PropertyName &propertyName) const
if (propertyName.contains('.')) {
const PropertyNameList parts = propertyName.split('.');
- const PropertyName objectName = parts.first();
- const PropertyName rawPropertyName = parts.last();
+ const PropertyName &objectName = parts.constFirst();
+ const PropertyName &rawPropertyName = parts.constLast();
const TypeName objectType = propertyType(objectName);
if (isValueType(objectType))
@@ -947,8 +947,8 @@ QString NodeMetaInfoPrivate::propertyEnumScope(const PropertyName &propertyName)
if (propertyName.contains('.')) {
const PropertyNameList parts = propertyName.split('.');
- const PropertyName objectName = parts.first();
- const PropertyName rawPropertyName = parts.last();
+ const PropertyName &objectName = parts.constFirst();
+ const PropertyName &rawPropertyName = parts.constLast();
const TypeName objectType = propertyType(objectName);
if (isValueType(objectType))
@@ -989,7 +989,7 @@ static QByteArray getUnqualifiedName(const QByteArray &name)
const QList<QByteArray> nameComponents = name.split('.');
if (nameComponents.size() < 2)
return name;
- return nameComponents.last();
+ return nameComponents.constLast();
}
static QByteArray getPackage(const QByteArray &name)
@@ -1138,7 +1138,7 @@ QString NodeMetaInfoPrivate::importDirectoryPath() const
if (isValid()) {
const Imports *imports = context()->imports(document());
- ImportInfo importInfo = imports->info(lookupNameComponent().last(), context().data());
+ ImportInfo importInfo = imports->info(lookupNameComponent().constLast(), context().data());
if (importInfo.type() == ImportType::Directory) {
return importInfo.path();