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 4ac872639e.
Pick-to: 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>
(cherry picked from commit 3ea877a844438af01337d77b1f813a2af04aba05)
bb10
parent
0f1a569cb6
commit
eab28dba44
|
|
@ -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…
Reference in New Issue