summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2021-08-12 14:51:19 +0200
committerMarc Mutz <marc.mutz@kdab.com>2021-08-16 19:26:29 +0200
commit991c471aa50e5b9944a5bcf4da3316263002d96d (patch)
treed411ffd0f8905986e90d762fcf348ea8659d2a53 /src
parentcfa631e0fb5d78aac80cb580eb092fafa1cd9a8f (diff)
QLibrary: succeed early for .dylib on Darwin
Drag the cheap check for 'fileName.endsWith(".dylib")' to before the expensive operations (QFileInfo creation, extraction and splitting of completeSuffix(), building of suffix candidate list, ...), at the cost of a duplicated Q_OS_DARWIN check. Change-Id: I8ed764f18f0beb8ad24c30ab806ecc5452159601 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/plugin/qlibrary.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index adac2f41da..79a6cfcdf2 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -664,6 +664,11 @@ bool QLibrary::isLibrary(const QString &fileName)
#if defined(Q_OS_WIN)
return fileName.endsWith(QLatin1String(".dll"), Qt::CaseInsensitive);
#else // Generic Unix
+# if defined(Q_OS_DARWIN)
+ // On Apple platforms, dylib look like libmylib.1.0.0.dylib
+ if (fileName.endsWith(QLatin1String(".dylib")))
+ return true;
+# endif
QString completeSuffix = QFileInfo(fileName).completeSuffix();
if (completeSuffix.isEmpty())
return false;
@@ -683,10 +688,6 @@ bool QLibrary::isLibrary(const QString &fileName)
# elif defined(Q_OS_AIX)
validSuffixList << QLatin1String("a") << QLatin1String("so");
# elif defined(Q_OS_DARWIN)
- // On Apple platforms, dylib look like libmylib.1.0.0.dylib
- if (suffixes.last() == QLatin1String("dylib"))
- return true;
-
validSuffixList << QLatin1String("so") << QLatin1String("bundle");
# elif defined(Q_OS_UNIX)
validSuffixList << QLatin1String("so");