diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2017-11-16 17:50:24 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2017-11-29 09:42:53 +0000 |
commit | dd57e76a4322887e526999835ad0c61761b41674 (patch) | |
tree | 51bcfd302c9cc9316b5b7443d5b9ccb0c9733bd3 /src/lib/corelib/generators | |
parent | 75ac4e1c20f99013ea307ec134c3f9b5b150f8b4 (diff) |
corelib: Gather string constants in central place
The same string literals appeared over and over again in the code base,
causing redundancy in the sources as well as at run-time. We now give
them a name and make sure they get instantiated at most once.
String literals that occur only once are converted from QLatin1String to
QStringLiteral unless they appear only in contexts that make use of
QLatin1String overloads or they are clearly outside of any hot code
paths.
This seems to result in small, but measurable performance improvements,
even if we assume the 1% changes to be noise:
========== Performance data for Resolving ==========
Old instruction count: 3266514138
New instruction count: 3209355927
Relative change: -2 %
Old peak memory usage: 29649896 Bytes
New peak memory usage: 29436264 Bytes
Relative change: -1 %
========== Performance data for Rule Execution ==========
Old instruction count: 3367804753
New instruction count: 3319029596
Relative change: -2 %
Old peak memory usage: 19577760 Bytes
New peak memory usage: 19091328 Bytes
Relative change: -3 %
========== Performance data for Null Build ==========
Old instruction count: 608946535
New instruction count: 604566001
Relative change: -1 %
Old peak memory usage: 14606384 Bytes
New peak memory usage: 14579936 Bytes
Relative change: -1 %
Change-Id: Ia055a52e0a4b6fe6fd0f1e7ba4bfa583cba1b0ef
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Diffstat (limited to 'src/lib/corelib/generators')
-rw-r--r-- | src/lib/corelib/generators/generator.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib/corelib/generators/generator.cpp b/src/lib/corelib/generators/generator.cpp index b81e65fe4..fae85ae15 100644 --- a/src/lib/corelib/generators/generator.cpp +++ b/src/lib/corelib/generators/generator.cpp @@ -43,6 +43,7 @@ #include <tools/hostosinfo.h> #include <tools/installoptions.h> #include <tools/qbsassert.h> +#include <tools/stringconstants.h> #include <QtCore/qcoreapplication.h> namespace qbs { @@ -69,8 +70,8 @@ ProjectGenerator::~ProjectGenerator() static QString _configurationName(const Project &project) { return project.projectConfiguration() - .value(QStringLiteral("qbs")).toMap() - .value(QStringLiteral("configurationName")).toString(); + .value(Internal::StringConstants::qbsModule()).toMap() + .value(Internal::StringConstants::configurationNameProperty()).toString(); } static QString _configurationName(const QVariantMap &buildConfiguration) |