QDir: replace an indexed loop with all_of()
Replaces ten LOC with int/qsizetype mismatches with two LOC with no ints in sight. For reviewers that don't know std::all_of: it's range conjunction aka universal quantifier, which means it returns true for the empty set. Task-number: QTBUG-103525 Pick-to: 6.4 6.3 6.2 Change-Id: I2423102631a66996b1faff7297c7fc365f0ffb12 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
d8561b1dea
commit
84277dda00
@ -87,16 +87,8 @@ QDirPrivate::QDirPrivate(const QString &path, const QStringList &nameFilters_, Q
|
|||||||
{
|
{
|
||||||
setPath(path.isEmpty() ? QString::fromLatin1(".") : path);
|
setPath(path.isEmpty() ? QString::fromLatin1(".") : path);
|
||||||
|
|
||||||
bool empty = nameFilters.isEmpty();
|
auto isEmpty = [](const auto &e) { return e.isEmpty(); };
|
||||||
if (!empty) {
|
const bool empty = std::all_of(nameFilters.cbegin(), nameFilters.cend(), isEmpty);
|
||||||
empty = true;
|
|
||||||
for (int i = 0; i < nameFilters.size(); ++i) {
|
|
||||||
if (!nameFilters.at(i).isEmpty()) {
|
|
||||||
empty = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (empty)
|
if (empty)
|
||||||
nameFilters = QStringList(QString::fromLatin1("*"));
|
nameFilters = QStringList(QString::fromLatin1("*"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user