diff options
| author | Marc Mutz <marc.mutz@qt.io> | 2022-09-30 14:09:04 +0200 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@qt.io> | 2022-11-03 14:59:24 +0100 |
| commit | 1c6bf3e09ea9722717caedcfcceaaf3d607615cf (patch) | |
| tree | cad1814e104667a84ba7b5f403bbda015413e058 /src/corelib/animation/qvariantanimation.cpp | |
| parent | 43cda7807b98552e9292ac09a1f6612d432a8b13 (diff) | |
Port from container::count() and length() to size() - V5
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to
handle typedefs and accesses through pointers, too:
const std::string o = "object";
auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); };
auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) {
auto exprOfDeclaredType = [&](auto decl) {
return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o);
};
return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))));
};
auto renameMethod = [&] (ArrayRef<StringRef> classes,
StringRef from, StringRef to) {
return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)),
callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))),
changeTo(cat(access(o, cat(to)), "()")),
cat("use '", to, "' instead of '", from, "'"));
};
renameMethod(<classes>, "count", "size");
renameMethod(<classes>, "length", "size");
except that the on() matcher has been replaced by one that doesn't
ignoreParens().
a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'.
Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache,
to avoid porting calls that explicitly test count().
Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/corelib/animation/qvariantanimation.cpp')
| -rw-r--r-- | src/corelib/animation/qvariantanimation.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp index cd9a01a1386..cf84200f2a5 100644 --- a/src/corelib/animation/qvariantanimation.cpp +++ b/src/corelib/animation/qvariantanimation.cpp @@ -156,7 +156,7 @@ void QVariantAnimationPrivate::convertValues(int t) { auto type = QMetaType(t); //this ensures that all the keyValues are of type t - for (int i = 0; i < keyValues.count(); ++i) { + for (int i = 0; i < keyValues.size(); ++i) { QVariantAnimation::KeyValue &pair = keyValues[i]; pair.second.convert(type); } @@ -190,7 +190,7 @@ void QVariantAnimationPrivate::updateInterpolator() void QVariantAnimationPrivate::recalculateCurrentInterval(bool force/*=false*/) { // can't interpolate if we don't have at least 2 values - if ((keyValues.count() + (defaultStartEndValue.isValid() ? 1 : 0)) < 2) + if ((keyValues.size() + (defaultStartEndValue.isValid() ? 1 : 0)) < 2) return; const qreal endProgress = (direction == QAbstractAnimation::Forward) ? qreal(1) : qreal(0); @@ -207,7 +207,7 @@ void QVariantAnimationPrivate::recalculateCurrentInterval(bool force/*=false*/) animationValueLessThan); if (it == keyValues.constBegin()) { //the item pointed to by it is the start element in the range - if (it->first == 0 && keyValues.count() > 1) { + if (it->first == 0 && keyValues.size() > 1) { currentInterval.start = *it; currentInterval.end = *(it+1); } else { @@ -216,7 +216,7 @@ void QVariantAnimationPrivate::recalculateCurrentInterval(bool force/*=false*/) } } else if (it == keyValues.constEnd()) { --it; //position the iterator on the last item - if (it->first == 1 && keyValues.count() > 1) { + if (it->first == 1 && keyValues.size() > 1) { //we have an end value (item with progress = 1) currentInterval.start = *(it-1); currentInterval.end = *it; @@ -405,7 +405,7 @@ void QVariantAnimation::registerInterpolator(QVariantAnimation::Interpolator fun // to continue causes the app to crash on exit with a SEGV if (interpolators) { const auto locker = qt_scoped_lock(registeredInterpolatorsMutex); - if (interpolationType >= interpolators->count()) + if (interpolationType >= interpolators->size()) interpolators->resize(interpolationType + 1); interpolators->replace(interpolationType, func); } @@ -423,7 +423,7 @@ QVariantAnimation::Interpolator QVariantAnimationPrivate::getInterpolator(int in QInterpolatorVector *interpolators = registeredInterpolators(); const auto locker = qt_scoped_lock(registeredInterpolatorsMutex); QVariantAnimation::Interpolator ret = nullptr; - if (interpolationType < interpolators->count()) { + if (interpolationType < interpolators->size()) { ret = interpolators->at(interpolationType); if (ret) return ret; } |
