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>
This commit is contained in:
parent
639ef6ca1a
commit
a545715c83
@ -531,39 +531,33 @@ static QStringList libraryPathList()
|
|||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_NEVER_INLINE
|
||||||
static QStringList findAllLibSsl()
|
static QStringList findAllLibs(QLatin1String filter)
|
||||||
{
|
{
|
||||||
QStringList paths = libraryPathList();
|
QStringList paths = libraryPathList();
|
||||||
QStringList foundSsls;
|
QStringList found;
|
||||||
|
const QStringList filters((QString(filter)));
|
||||||
|
|
||||||
foreach (const QString &path, paths) {
|
foreach (const QString &path, paths) {
|
||||||
QDir dir(path);
|
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());
|
std::sort(entryList.begin(), entryList.end(), LibGreaterThan());
|
||||||
foreach (const QString &entry, entryList)
|
foreach (const QString &entry, entryList)
|
||||||
foundSsls << path + QLatin1Char('/') + entry;
|
found << path + QLatin1Char('/') + entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
return foundSsls;
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
static QStringList findAllLibSsl()
|
||||||
|
{
|
||||||
|
return findAllLibs(QLatin1String("libssl.*"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static QStringList findAllLibCrypto()
|
static QStringList findAllLibCrypto()
|
||||||
{
|
{
|
||||||
QStringList paths = libraryPathList();
|
return findAllLibs(QLatin1String("libcrypto.*"));
|
||||||
|
|
||||||
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 foundCryptos;
|
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user