From 87ba5348e915b8c91651df44c08fe3e3b016e0a0 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 12 Feb 2025 18:46:21 -0800 Subject: [PATCH] QCoreApplication: remove the applicationDirPath() cache It's just a string manipulation and it's not that important to keep cached. Especially since we wouldn't update it when applicationFilePath()'s cache was invalidated on argv[0] change: if (d->argc) { static QByteArray procName = QByteArray(d->argv[0]); if (procName != QByteArrayView(d->argv[0])) { // clear the cache if the procname changes, so we reprocess it. d->cachedApplicationFilePath = QString(); procName.assign(d->argv[0]); } } Amends commit e6f483c0e802969e79aca5b37ef3f4912a6e25d7. Change-Id: I52a4cd2ebf500a941d5dfffd4b5e10ff22523d61 Reviewed-by: Ahmad Samir --- src/corelib/kernel/qcoreapplication.cpp | 5 +---- src/corelib/kernel/qcoreapplication_p.h | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 5008ed579dd..87d7ab434c2 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -2382,10 +2382,7 @@ QString QCoreApplication::applicationDirPath() return QString(); } - QCoreApplicationPrivate *d = self->d_func(); - if (d->cachedApplicationDirPath.isNull()) - d->cachedApplicationDirPath = QFileInfo(applicationFilePath()).path(); - return d->cachedApplicationDirPath; + return QFileInfo(applicationFilePath()).path(); } #if !defined(Q_OS_WIN) && !defined(Q_OS_DARWIN) diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index 98a5af29167..0027b1ad57f 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -157,7 +157,6 @@ public: static inline bool testAttribute(uint flag) { return attribs & (1 << flag); } void processCommandLineArguments(); - QString cachedApplicationDirPath; QString cachedApplicationFilePath; QString qmljs_debug_arguments; // a string containing arguments for js/qml debugging. inline QString qmljsDebugArgumentsString() const { return qmljs_debug_arguments; }