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. Pick-to: 6.3 Change-Id: I6fcda969a9e9427198bffffd16ce8d1eb8dc19da Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
8b87c6f198
commit
8058127a9d
@ -211,7 +211,8 @@ Option::parseCommandLine(QStringList &args, QMakeCmdLineParserState &state)
|
|||||||
fprintf(stderr, "***Option %s requires a parameter\n", qPrintable(args.at(x - 1)));
|
fprintf(stderr, "***Option %s requires a parameter\n", qPrintable(args.at(x - 1)));
|
||||||
return Option::QMAKE_CMDLINE_SHOW_USAGE | Option::QMAKE_CMDLINE_ERROR;
|
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)
|
if (cmdRet == QMakeGlobals::ArgumentsOk)
|
||||||
break;
|
break;
|
||||||
Q_ASSERT(cmdRet == QMakeGlobals::ArgumentUnknown);
|
Q_ASSERT(cmdRet == QMakeGlobals::ArgumentUnknown);
|
||||||
|
@ -123,8 +123,8 @@ void QLibrarySettings::load()
|
|||||||
|
|
||||||
static QSettings *findConfiguration()
|
static QSettings *findConfiguration()
|
||||||
{
|
{
|
||||||
if (!QLibraryInfoPrivate::qtconfManualPath.isEmpty())
|
if (QLibraryInfoPrivate::qtconfManualPath)
|
||||||
return new QSettings(QLibraryInfoPrivate::qtconfManualPath, QSettings::IniFormat);
|
return new QSettings(*QLibraryInfoPrivate::qtconfManualPath, QSettings::IniFormat);
|
||||||
|
|
||||||
QString qtconfig = QStringLiteral(":/qt/etc/qt.conf");
|
QString qtconfig = QStringLiteral(":/qt/etc/qt.conf");
|
||||||
if (QFile::exists(qtconfig))
|
if (QFile::exists(qtconfig))
|
||||||
@ -156,7 +156,7 @@ static QSettings *findConfiguration()
|
|||||||
return nullptr; //no luck
|
return nullptr; //no luck
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QLibraryInfoPrivate::qtconfManualPath;
|
const QString *QLibraryInfoPrivate::qtconfManualPath = nullptr;
|
||||||
|
|
||||||
QSettings *QLibraryInfoPrivate::configuration()
|
QSettings *QLibraryInfoPrivate::configuration()
|
||||||
{
|
{
|
||||||
|
@ -67,7 +67,7 @@ public:
|
|||||||
#if QT_CONFIG(settings)
|
#if QT_CONFIG(settings)
|
||||||
static QSettings *configuration();
|
static QSettings *configuration();
|
||||||
static void reload();
|
static void reload();
|
||||||
static QString qtconfManualPath;
|
static const QString *qtconfManualPath;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct LocationInfo
|
struct LocationInfo
|
||||||
|
@ -170,6 +170,7 @@ static QString searchStringOrError(QCommandLineParser *parser)
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
QString qtconfManualPath;
|
||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
app.setApplicationVersion(QTPATHS_VERSION_STR);
|
app.setApplicationVersion(QTPATHS_VERSION_STR);
|
||||||
|
|
||||||
@ -267,7 +268,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
#if QT_CONFIG(settings)
|
#if QT_CONFIG(settings)
|
||||||
if (parser.isSet(qtconf)) {
|
if (parser.isSet(qtconf)) {
|
||||||
QLibraryInfoPrivate::qtconfManualPath = parser.value(qtconf);
|
qtconfManualPath = parser.value(qtconf);
|
||||||
|
QLibraryInfoPrivate::qtconfManualPath = &qtconfManualPath;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user