diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-08-17 22:09:26 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-08-21 08:29:17 +0200 |
commit | 84277dda00c6f43a2ebe788c5c72b9c891fb3579 (patch) | |
tree | 5a34896497739fd3f6ad83c2513b4e796ae7212e /src/corelib/io/qdir.cpp | |
parent | d8561b1dea4a4cabebcba38ddf2d5b67afa5826e (diff) |
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>
Diffstat (limited to 'src/corelib/io/qdir.cpp')
-rw-r--r-- | src/corelib/io/qdir.cpp | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 09315f9afe..26f30fba6a 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -87,16 +87,8 @@ QDirPrivate::QDirPrivate(const QString &path, const QStringList &nameFilters_, Q { setPath(path.isEmpty() ? QString::fromLatin1(".") : path); - bool empty = nameFilters.isEmpty(); - if (!empty) { - empty = true; - for (int i = 0; i < nameFilters.size(); ++i) { - if (!nameFilters.at(i).isEmpty()) { - empty = false; - break; - } - } - } + auto isEmpty = [](const auto &e) { return e.isEmpty(); }; + const bool empty = std::all_of(nameFilters.cbegin(), nameFilters.cend(), isEmpty); if (empty) nameFilters = QStringList(QString::fromLatin1("*")); } |