summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2022-04-21 10:45:47 +0200
committerMarco Bubke <marco.bubke@qt.io>2022-05-24 16:03:03 +0000
commit69858337da0b6b007c39c5aa17e0ec3d9d5ed228 (patch)
tree2c3bcef8f4f772e70c5643e39a9f396c7c106c01
parent056db316f926607db0922d03746f91317410ad66 (diff)
downloadqt-creator-69858337da0b6b007c39c5aa17e0ec3d9d5ed228.tar.gz
QmlDesigner: Use TypeNameString instead of Utils::SmallString
It increases the small string optimization area. Many of the type names are longer than the SSO area of Utils::SmallString so we use a custom String for types which has a larger SSO area. So there a much less mallocs. This should improve performance a little but but uses a little bit more memory. Change-Id: I6a2225f21fb16afc8379868f3f18f38ae6ad0cd8 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
-rw-r--r--src/plugins/qmldesigner/designercore/projectstorage/projectstoragetypes.h14
-rw-r--r--src/plugins/qmldesigner/designercore/projectstorage/qmltypesparser.cpp37
2 files changed, 26 insertions, 25 deletions
diff --git a/src/plugins/qmldesigner/designercore/projectstorage/projectstoragetypes.h b/src/plugins/qmldesigner/designercore/projectstorage/projectstoragetypes.h
index 4fd92a9475..f025babdb0 100644
--- a/src/plugins/qmldesigner/designercore/projectstorage/projectstoragetypes.h
+++ b/src/plugins/qmldesigner/designercore/projectstorage/projectstoragetypes.h
@@ -43,6 +43,8 @@ constexpr std::underlying_type_t<Enumeration> to_underlying(Enumeration enumerat
return static_cast<std::underlying_type_t<Enumeration>>(enumeration);
}
+using TypeNameString = Utils::BasicSmallString<63>;
+
} // namespace QmlDesigner
namespace QmlDesigner::Storage {
@@ -310,7 +312,7 @@ public:
}
public:
- Utils::SmallString name;
+ TypeNameString name;
};
class QualifiedImportedType
@@ -328,7 +330,7 @@ public:
}
public:
- Utils::SmallString name;
+ TypeNameString name;
Import import;
};
@@ -459,7 +461,7 @@ public:
}
public:
- Utils::SmallString name;
+ TypeNameString name;
EnumeratorDeclarations enumeratorDeclarations;
};
@@ -509,7 +511,7 @@ public:
public:
Utils::SmallString name;
- Utils::SmallString typeName;
+ TypeNameString typeName;
PropertyDeclarationTraits traits = {};
};
@@ -584,7 +586,7 @@ public:
public:
Utils::SmallString name;
- Utils::SmallString returnTypeName;
+ TypeNameString returnTypeName;
ParameterDeclarations parameters;
};
@@ -806,7 +808,7 @@ public:
}
public:
- Utils::SmallString typeName;
+ TypeNameString typeName;
ImportedTypeName prototype;
ExportedTypes exportedTypes;
PropertyDeclarations propertyDeclarations;
diff --git a/src/plugins/qmldesigner/designercore/projectstorage/qmltypesparser.cpp b/src/plugins/qmldesigner/designercore/projectstorage/qmltypesparser.cpp
index 796f8a9977..cd879d33c1 100644
--- a/src/plugins/qmldesigner/designercore/projectstorage/qmltypesparser.cpp
+++ b/src/plugins/qmldesigner/designercore/projectstorage/qmltypesparser.cpp
@@ -128,22 +128,21 @@ Storage::ExportedTypes createExports(const QList<QQmlJSScope::Export> &qmlExport
exportedTypes.reserve(Utils::usize(qmlExports));
for (const QQmlJSScope::Export &qmlExport : qmlExports) {
- Utils::SmallString exportedTypeName{qmlExport.type()};
+ TypeNameString exportedTypeName{qmlExport.type()};
exportedTypes.emplace_back(storage.moduleId(Utils::SmallString{qmlExport.package()}),
std::move(exportedTypeName),
createVersion(qmlExport.version()));
}
- Utils::SmallString cppExportedTypeName{interanalName};
+ TypeNameString cppExportedTypeName{interanalName};
exportedTypes.emplace_back(cppModuleId, cppExportedTypeName);
return exportedTypes;
}
-Utils::SmallString createCppEnumerationExport(Utils::SmallStringView typeName,
- Utils::SmallStringView enumerationName)
+auto createCppEnumerationExport(Utils::SmallStringView typeName, Utils::SmallStringView enumerationName)
{
- Utils::SmallString cppExportedTypeName{typeName};
+ TypeNameString cppExportedTypeName{typeName};
cppExportedTypeName += "::";
cppExportedTypeName += enumerationName;
@@ -194,13 +193,13 @@ struct EnumerationType
{}
Utils::SmallString name;
- Utils::SmallString full;
+ TypeNameString full;
};
using EnumerationTypes = std::vector<EnumerationType>;
-Utils::SmallString fullyQualifiedTypeName(const QString &typeName,
- const ComponentWithoutNamespaces &componentNameWithoutNamespace)
+TypeNameString fullyQualifiedTypeName(const QString &typeName,
+ const ComponentWithoutNamespaces &componentNameWithoutNamespace)
{
if (auto found = componentNameWithoutNamespace.find(typeName);
found != componentNameWithoutNamespace.end())
@@ -221,7 +220,7 @@ Storage::PropertyDeclarations createProperties(
if (qmlProperty.typeName().isEmpty())
continue;
- Utils::SmallString propertyTypeName{
+ TypeNameString propertyTypeName{
fullyQualifiedTypeName(qmlProperty.typeName(), componentNameWithoutNamespace)};
auto found = find_if(enumerationTypes.begin(), enumerationTypes.end(), [&](auto &entry) {
@@ -327,18 +326,18 @@ Storage::EnumerationDeclarations createEnumeration(const QHash<QString, QQmlJSMe
enumerationDeclarations.reserve(Utils::usize(qmlEnumerations));
for (const QQmlJSMetaEnum &qmlEnumeration : qmlEnumerations) {
- enumerationDeclarations.emplace_back(Utils::SmallString{qmlEnumeration.name()},
+ enumerationDeclarations.emplace_back(TypeNameString{qmlEnumeration.name()},
createEnumerators(qmlEnumeration));
}
return enumerationDeclarations;
}
-Utils::SmallString addEnumerationType(EnumerationTypes &enumerationTypes,
- Utils::SmallStringView typeName,
- Utils::SmallStringView enumerationName)
+auto addEnumerationType(EnumerationTypes &enumerationTypes,
+ Utils::SmallStringView typeName,
+ Utils::SmallStringView enumerationName)
{
- auto fullTypeName = Utils::SmallString::join({typeName, "::", enumerationName});
+ auto fullTypeName = TypeNameString::join({typeName, "::", enumerationName});
enumerationTypes.emplace_back(enumerationName, std::move(fullTypeName));
return fullTypeName;
@@ -354,7 +353,7 @@ void addEnumerationType(EnumerationTypes &enumerationTypes,
{
auto fullTypeName = addEnumerationType(enumerationTypes, typeName, enumerationName);
types.emplace_back(fullTypeName,
- Storage::ImportedType{Utils::SmallString{}},
+ Storage::ImportedType{TypeNameString{}},
Storage::TypeAccessSemantics::Value | Storage::TypeAccessSemantics::IsEnum,
sourceId,
createCppEnumerationExports(typeName,
@@ -393,8 +392,8 @@ EnumerationTypes addEnumerationTypes(Storage::Types &types,
if (aliases.contains(qmlEnumeration.name()))
continue;
- Utils::SmallString enumerationName{qmlEnumeration.name()};
- Utils::SmallString enumerationAlias{qmlEnumeration.alias()};
+ TypeNameString enumerationName{qmlEnumeration.name()};
+ TypeNameString enumerationAlias{qmlEnumeration.alias()};
addEnumerationType(enumerationTypes,
types,
typeName,
@@ -416,13 +415,13 @@ void addType(Storage::Types &types,
{
auto [functionsDeclarations, signalDeclarations] = createFunctionAndSignals(
component.ownMethods(), componentNameWithoutNamespace);
- Utils::SmallString typeName{component.internalName()};
+ TypeNameString typeName{component.internalName()};
auto enumerations = component.ownEnumerations();
auto exports = component.exports();
auto enumerationTypes = addEnumerationTypes(types, typeName, sourceId, cppModuleId, enumerations);
types.emplace_back(Utils::SmallStringView{typeName},
- Storage::ImportedType{Utils::SmallString{component.baseTypeName()}},
+ Storage::ImportedType{TypeNameString{component.baseTypeName()}},
createTypeAccessSemantics(component.accessSemantics()),
sourceId,
createExports(exports, typeName, storage, cppModuleId),