From 69858337da0b6b007c39c5aa17e0ec3d9d5ed228 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Thu, 21 Apr 2022 10:45:47 +0200 Subject: 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 --- .../projectstorage/projectstoragetypes.h | 14 ++++---- .../designercore/projectstorage/qmltypesparser.cpp | 37 +++++++++++----------- 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 to_underlying(Enumeration enumerat return static_cast>(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 &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; -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