QLibraryInfo: de-pessimize prefixFromAppDirHelper()
The local appDir variable was only used to hold the return value of another function call. But hardly any compiler will be able to look through the QString atomic ref-counting to turn the non-Darwin code paths into the tail-calls that they ought to be. Remove the variable and return the result immediately. This removes the move-assignment and dtor calls in the two changed lines and lets RVO kick in, turning these calls into tail-calls on non-Darwin platforms. Amends 4ac872639ed0dd3ae6627e05bdda821f7d128500. Pick-to: 6.8 6.5 Change-Id: Ieeefbd52fc983ab7aebcff6419965b206f374935 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> (cherry picked from commit e57113feac183abd1f5bfcfb633a33e1387b2d3e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
60a264ed50
commit
3ea877a844
@ -269,8 +269,6 @@ QVersionNumber QLibraryInfo::version() noexcept
|
||||
|
||||
static QString prefixFromAppDirHelper()
|
||||
{
|
||||
QString appDir;
|
||||
|
||||
if (QCoreApplication::instance()) {
|
||||
#ifdef Q_OS_DARWIN
|
||||
CFBundleRef bundleRef = CFBundleGetMainBundle();
|
||||
@ -289,12 +287,10 @@ static QString prefixFromAppDirHelper()
|
||||
}
|
||||
#endif // Q_OS_DARWIN
|
||||
// We make the prefix path absolute to the executable's directory.
|
||||
appDir = QCoreApplication::applicationDirPath();
|
||||
return QCoreApplication::applicationDirPath();
|
||||
} else {
|
||||
appDir = QDir::currentPath();
|
||||
return QDir::currentPath();
|
||||
}
|
||||
|
||||
return appDir;
|
||||
}
|
||||
|
||||
#if QT_CONFIG(relocatable)
|
||||
|
Loading…
x
Reference in New Issue
Block a user