Don't cache QCoreApplication::appName.

This isn't a hot codepath, there is no gain to doing this. It introduces
unnecessary bloat (see e.g.
https://www.webkit.org/blog/2826/unusual-speed-boost-size-matters/) and
complicates boosting Qt application startup in cases where argv[0] is
overwritten.

Change-Id: I55b2b98b0de6b06fe7a049de262f3e19936b73db
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Robin Burchell 2013-10-08 22:41:20 +02:00 committed by The Qt Project
parent 04de24c644
commit 418e06f78f
2 changed files with 5 additions and 10 deletions

View File

@ -147,17 +147,13 @@ QString QCoreApplicationPrivate::macMenuBarName()
#endif
QString QCoreApplicationPrivate::appName() const
{
static QBasicMutex applicationNameMutex;
QMutexLocker locker(&applicationNameMutex);
if (applicationName.isNull()) {
QString applicationName;
#ifdef Q_OS_MAC
applicationName = macMenuBarName();
applicationName = macMenuBarName();
#endif
if (applicationName.isEmpty() && argv[0]) {
char *p = strrchr(argv[0], '/');
applicationName = QString::fromLocal8Bit(p ? p + 1 : argv[0]);
}
if (applicationName.isEmpty() && argv[0]) {
char *p = strrchr(argv[0], '/');
applicationName = QString::fromLocal8Bit(p ? p + 1 : argv[0]);
}
return applicationName;

View File

@ -83,7 +83,6 @@ public:
~QCoreApplicationPrivate();
QString appName() const;
mutable QString applicationName;
#ifdef Q_OS_MAC
static QString macMenuBarName();