summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-01-25 13:30:25 +0100
committerMarc Mutz <marc.mutz@kdab.com>2016-02-19 18:11:55 +0000
commit342acf66fe640c72e1a7c8837ba5cdefae06f9c9 (patch)
treec42718bd8e29d82661f7c6053b259c2dd5dbf2ec /src/tools
parentbcc965ef4bae2565456522b19687a3e726da8315 (diff)
uic: optimize string handling in WriteInitialization::acceptWidget()
Instead of building QStringLists out of statically-known US-ASCII strings, use C arrays of QLatin1String instead. QLatin1String is constexpr, so these tables, while causing relocations, do not require runtime initialization. Using QStringBuilder, these QLatin1Strings are almost a drop-in replacement for the QStrings used before. Effects on optimized GCC 5.3 Linux AMD64 builds: $ size bin/uic-* text data bss dec hex filename 567104 31776 56 598936 92398 bin/uic-00-before 565829 31944 24 597797 91f25 bin/uic-01-after Change-Id: I469c62b0e8966731d7ac2fa092f4b4cd8ddb79f1 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.cpp42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp
index 67195c5f8b..0886cf4c4a 100644
--- a/src/tools/uic/cpp/cppwriteinitialization.cpp
+++ b/src/tools/uic/cpp/cppwriteinitialization.cpp
@@ -770,22 +770,23 @@ void WriteInitialization::acceptWidget(DomWidget *node)
//
// Special handling for qtableview/qtreeview fake header attributes
//
- static QStringList realPropertyNames =
- (QStringList() << QLatin1String("visible")
- << QLatin1String("cascadingSectionResizes")
- << QLatin1String("defaultSectionSize")
- << QLatin1String("highlightSections")
- << QLatin1String("minimumSectionSize")
- << QLatin1String("showSortIndicator")
- << QLatin1String("stretchLastSection"));
+ static const QLatin1String realPropertyNames[] = {
+ QLatin1String("visible"),
+ QLatin1String("cascadingSectionResizes"),
+ QLatin1String("defaultSectionSize"),
+ QLatin1String("highlightSections"),
+ QLatin1String("minimumSectionSize"),
+ QLatin1String("showSortIndicator"),
+ QLatin1String("stretchLastSection"),
+ };
if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QTreeView"))
|| m_uic->customWidgetsInfo()->extends(className, QLatin1String("QTreeWidget"))) {
DomPropertyList headerProperties;
- foreach (const QString &realPropertyName, realPropertyNames) {
- const QString upperPropertyName = realPropertyName.at(0).toUpper()
- + realPropertyName.mid(1);
- const QString fakePropertyName = QLatin1String("header") + upperPropertyName;
+ for (auto realPropertyName : realPropertyNames) {
+ const QString fakePropertyName = QLatin1String("header")
+ + QChar(QLatin1Char(realPropertyName.data()[0])).toUpper()
+ + QLatin1String(realPropertyName.data() + 1, realPropertyName.size() - 1);
if (DomProperty *fakeProperty = attributes.value(fakePropertyName)) {
fakeProperty->setAttributeName(realPropertyName);
headerProperties << fakeProperty;
@@ -797,16 +798,17 @@ void WriteInitialization::acceptWidget(DomWidget *node)
} else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QTableView"))
|| m_uic->customWidgetsInfo()->extends(className, QLatin1String("QTableWidget"))) {
- static QStringList headerPrefixes =
- (QStringList() << QLatin1String("horizontalHeader")
- << QLatin1String("verticalHeader"));
+ static const QLatin1String headerPrefixes[] = {
+ QLatin1String("horizontalHeader"),
+ QLatin1String("verticalHeader"),
+ };
- foreach (const QString &headerPrefix, headerPrefixes) {
+ for (auto headerPrefix : headerPrefixes) {
DomPropertyList headerProperties;
- foreach (const QString &realPropertyName, realPropertyNames) {
- const QString upperPropertyName = realPropertyName.at(0).toUpper()
- + realPropertyName.mid(1);
- const QString fakePropertyName = headerPrefix + upperPropertyName;
+ for (auto realPropertyName : realPropertyNames) {
+ const QString fakePropertyName = headerPrefix
+ + QChar(QLatin1Char(realPropertyName.data()[0])).toUpper()
+ + QLatin1String(realPropertyName.data() + 1, realPropertyName.size() - 1);
if (DomProperty *fakeProperty = attributes.value(fakePropertyName)) {
fakeProperty->setAttributeName(realPropertyName);
headerProperties << fakeProperty;