summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-01-28 13:41:17 -0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-03-16 19:04:02 +0000
commit27af1b9dc42c6b3eeade9bec1943c1e6527b14d0 (patch)
treeb65fc9db8f98d6d97d8dc22cd5c39796b0566985
parent89e8a07a90a4ebbdf71425f8edbdea8a6489c642 (diff)
QLibraryInfo: remove load-time variable
Since this is only used by qtpaths and qmake, let's not make every application pay the price of dynamically initializing a QString whenever QtCore is loaded (which 100% of Qt applications do). Instead, initializing a null pointer costs zero and is one third the size of QString. Even the assignment in qmake and qtpaths is faster this way. Change-Id: I6fcda969a9e9427198bffffd16ce8d1eb8dc19da Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit 8058127a9df0b66f28908f42e4f533165468de95) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--qmake/option.cpp3
-rw-r--r--src/corelib/global/qlibraryinfo.cpp6
-rw-r--r--src/corelib/global/qlibraryinfo_p.h2
-rw-r--r--src/tools/qtpaths/qtpaths.cpp4
4 files changed, 9 insertions, 6 deletions
diff --git a/qmake/option.cpp b/qmake/option.cpp
index 72edf9c271..f5fa85708e 100644
--- a/qmake/option.cpp
+++ b/qmake/option.cpp
@@ -208,7 +208,8 @@ Option::parseCommandLine(QStringList &args, QMakeCmdLineParserState &state)
fprintf(stderr, "***Option %s requires a parameter\n", qPrintable(args.at(x - 1)));
return Option::QMAKE_CMDLINE_SHOW_USAGE | Option::QMAKE_CMDLINE_ERROR;
}
- QLibraryInfoPrivate::qtconfManualPath = globals->qtconf;
+ if (!globals->qtconf.isEmpty())
+ QLibraryInfoPrivate::qtconfManualPath = &globals->qtconf;
if (cmdRet == QMakeGlobals::ArgumentsOk)
break;
Q_ASSERT(cmdRet == QMakeGlobals::ArgumentUnknown);
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index 0ae41cc48e..7b05a52caf 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -123,8 +123,8 @@ void QLibrarySettings::load()
static QSettings *findConfiguration()
{
- if (!QLibraryInfoPrivate::qtconfManualPath.isEmpty())
- return new QSettings(QLibraryInfoPrivate::qtconfManualPath, QSettings::IniFormat);
+ if (QLibraryInfoPrivate::qtconfManualPath)
+ return new QSettings(*QLibraryInfoPrivate::qtconfManualPath, QSettings::IniFormat);
QString qtconfig = QStringLiteral(":/qt/etc/qt.conf");
if (QFile::exists(qtconfig))
@@ -156,7 +156,7 @@ static QSettings *findConfiguration()
return nullptr; //no luck
}
-QString QLibraryInfoPrivate::qtconfManualPath;
+const QString *QLibraryInfoPrivate::qtconfManualPath = nullptr;
QSettings *QLibraryInfoPrivate::configuration()
{
diff --git a/src/corelib/global/qlibraryinfo_p.h b/src/corelib/global/qlibraryinfo_p.h
index caed0feb84..f335c0d01a 100644
--- a/src/corelib/global/qlibraryinfo_p.h
+++ b/src/corelib/global/qlibraryinfo_p.h
@@ -67,7 +67,7 @@ public:
#if QT_CONFIG(settings)
static QSettings *configuration();
static void reload();
- static QString qtconfManualPath;
+ static const QString *qtconfManualPath;
#endif
struct LocationInfo
diff --git a/src/tools/qtpaths/qtpaths.cpp b/src/tools/qtpaths/qtpaths.cpp
index 667b594b67..6e57ce9d4a 100644
--- a/src/tools/qtpaths/qtpaths.cpp
+++ b/src/tools/qtpaths/qtpaths.cpp
@@ -168,6 +168,7 @@ static QString searchStringOrError(QCommandLineParser *parser)
int main(int argc, char **argv)
{
+ QString qtconfManualPath;
QCoreApplication app(argc, argv);
app.setApplicationVersion(QTPATHS_VERSION_STR);
@@ -265,7 +266,8 @@ int main(int argc, char **argv)
#if QT_CONFIG(settings)
if (parser.isSet(qtconf)) {
- QLibraryInfoPrivate::qtconfManualPath = parser.value(qtconf);
+ qtconfManualPath = parser.value(qtconf);
+ QLibraryInfoPrivate::qtconfManualPath = &qtconfManualPath;
}
#endif