summaryrefslogtreecommitdiffstats
path: root/src/network/ssl/qsslsocket_openssl_symbols.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-07-12 00:49:02 +0200
committerMarc Mutz <marc.mutz@kdab.com>2015-07-13 22:28:17 +0000
commita545715c8317f79699610a58e15f4c48e9c1501e (patch)
treea0fbb8575b035cfe502dfa7d1defff92636e8b7c /src/network/ssl/qsslsocket_openssl_symbols.cpp
parent639ef6ca1a89188ad1e208d491f6c90253df7c59 (diff)
QSslSocket: remove code duplication
Since findAllLibSsl() and findAllLibCrypto() differ only in the filter passed to QDir::entryList(), so Extract Method findAllLibs(). In the new function, cache the filters QStringList instead of re-create it in every loop iteration. Change-Id: I1bdd05e83fa1f9bb3f47b9b2ae5da9654ec1525b Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'src/network/ssl/qsslsocket_openssl_symbols.cpp')
-rw-r--r--src/network/ssl/qsslsocket_openssl_symbols.cpp32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp
index f9a9d22781..f12d2ab798 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols.cpp
+++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp
@@ -531,39 +531,33 @@ static QStringList libraryPathList()
return paths;
}
-
-static QStringList findAllLibSsl()
+Q_NEVER_INLINE
+static QStringList findAllLibs(QLatin1String filter)
{
QStringList paths = libraryPathList();
- QStringList foundSsls;
+ QStringList found;
+ const QStringList filters((QString(filter)));
foreach (const QString &path, paths) {
QDir dir(path);
- QStringList entryList = dir.entryList(QStringList() << QLatin1String("libssl.*"), QDir::Files);
+ QStringList entryList = dir.entryList(filters, QDir::Files);
std::sort(entryList.begin(), entryList.end(), LibGreaterThan());
foreach (const QString &entry, entryList)
- foundSsls << path + QLatin1Char('/') + entry;
+ found << path + QLatin1Char('/') + entry;
}
- return foundSsls;
+ return found;
}
-static QStringList findAllLibCrypto()
+static QStringList findAllLibSsl()
{
- QStringList paths = libraryPathList();
-
- QStringList foundCryptos;
- foreach (const QString &path, paths) {
- QDir dir(path);
- QStringList entryList = dir.entryList(QStringList() << QLatin1String("libcrypto.*"), QDir::Files);
-
- std::sort(entryList.begin(), entryList.end(), LibGreaterThan());
- foreach (const QString &entry, entryList)
- foundCryptos << path + QLatin1Char('/') + entry;
- }
+ return findAllLibs(QLatin1String("libssl.*"));
+}
- return foundCryptos;
+static QStringList findAllLibCrypto()
+{
+ return findAllLibs(QLatin1String("libcrypto.*"));
}
# endif