diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-10-05 07:54:03 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-10-07 17:17:19 +0200 |
commit | bf9a1e31a194adfdbb7116455633b9046b34504c (patch) | |
tree | 53b90400cea484d9ad6da0c93b67da6bb351fba8 /src | |
parent | d20bdbb041948737df13934418b8a3ec4979fc9b (diff) |
Port from container::count() and length() to size()
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8:
auto QtContainerClass = anyOf(
expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o),
expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o));
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container',
with the extended set of container classes recognized.
Change-Id: I90d9db5c161f499cfabf3ce41f55c3cc4d4ff5d4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/multimedia/qmediastoragelocation.cpp | 2 | ||||
-rw-r--r-- | src/multimedia/qmediatimerange.cpp | 14 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/multimedia/qmediastoragelocation.cpp b/src/multimedia/qmediastoragelocation.cpp index 3b94198af..4363e06de 100644 --- a/src/multimedia/qmediastoragelocation.cpp +++ b/src/multimedia/qmediastoragelocation.cpp @@ -35,7 +35,7 @@ static QString generateFileName(const QDir &dir, const QString &prefix, const QS auto lastMediaIndex = 0; const auto list = dir.entryList({ QString::fromLatin1("%1*.%2").arg(prefix, extension) }); for (const QString &fileName : list) { - auto mediaIndex = QStringView{fileName}.mid(prefix.length(), fileName.size() - prefix.length() - extension.length() - 1).toInt(); + auto mediaIndex = QStringView{fileName}.mid(prefix.size(), fileName.size() - prefix.size() - extension.size() - 1).toInt(); lastMediaIndex = qMax(lastMediaIndex, mediaIndex); } diff --git a/src/multimedia/qmediatimerange.cpp b/src/multimedia/qmediatimerange.cpp index 51e82d32b..2af9cefc6 100644 --- a/src/multimedia/qmediatimerange.cpp +++ b/src/multimedia/qmediatimerange.cpp @@ -130,7 +130,7 @@ void QMediaTimeRangePrivate::addInterval(const QMediaTimeRange::Interval &interv // Find a place to insert the interval int i; - for (i = 0; i < intervals.count(); i++) { + for (i = 0; i < intervals.size(); i++) { // Insert before this element if(interval.s < intervals[i].s) { intervals.insert(i, interval); @@ -139,7 +139,7 @@ void QMediaTimeRangePrivate::addInterval(const QMediaTimeRange::Interval &interv } // Interval needs to be added to the end of the list - if (i == intervals.count()) + if (i == intervals.size()) intervals.append(interval); // Do we need to correct the element before us? @@ -147,7 +147,7 @@ void QMediaTimeRangePrivate::addInterval(const QMediaTimeRange::Interval &interv i--; // Merge trailing ranges - while (i < intervals.count() - 1 + while (i < intervals.size() - 1 && intervals[i].e >= intervals[i + 1].s - 1) { intervals[i].e = qMax(intervals[i].e, intervals[i + 1].e); intervals.removeAt(i + 1); @@ -160,7 +160,7 @@ void QMediaTimeRangePrivate::removeInterval(const QMediaTimeRange::Interval &int if (!interval.isNormal()) return; - for (int i = 0; i < intervals.count(); i++) { + for (int i = 0; i < intervals.size(); i++) { const QMediaTimeRange::Interval r = intervals.at(i); if (r.e < interval.s) { @@ -317,7 +317,7 @@ qint64 QMediaTimeRange::earliestTime() const qint64 QMediaTimeRange::latestTime() const { if (!d->intervals.isEmpty()) - return d->intervals[d->intervals.count() - 1].end(); + return d->intervals[d->intervals.size() - 1].end(); return 0; } @@ -506,7 +506,7 @@ bool QMediaTimeRange::isEmpty() const */ bool QMediaTimeRange::isContinuous() const { - return (d->intervals.count() <= 1); + return (d->intervals.size() <= 1); } /*! @@ -516,7 +516,7 @@ bool QMediaTimeRange::isContinuous() const */ bool QMediaTimeRange::contains(qint64 time) const { - for (int i = 0; i < d->intervals.count(); i++) { + for (int i = 0; i < d->intervals.size(); i++) { if (d->intervals[i].contains(time)) return true; |