diff options
| author | Marc Mutz <marc.mutz@qt.io> | 2022-10-05 07:29:16 +0200 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@qt.io> | 2022-10-07 23:38:48 +0200 |
| commit | 958cd3ee1094a068b6d0ff27c73a4b3caff088ad (patch) | |
| tree | 6d3816fedf5dab2307675fd6ef70d39758e246f5 /src/qml/jsruntime/qv4regexpobject.cpp | |
| parent | e8e03215654ca730243336a80453cf9396cbdf58 (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: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4regexpobject.cpp')
| -rw-r--r-- | src/qml/jsruntime/qv4regexpobject.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index 1b62717efc..acb9f0acfc 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -46,7 +46,7 @@ void Heap::RegExpObject::init(QV4::RegExp *value) static QString minimalPattern(const QString &pattern) { QString ecmaPattern; - int len = pattern.length(); + int len = pattern.size(); ecmaPattern.reserve(len); int i = 0; const QChar *wc = pattern.unicode(); @@ -144,7 +144,7 @@ ReturnedValue RegExpObject::builtinExec(ExecutionEngine *engine, const String *s Scope scope(engine); int offset = (global() || sticky()) ? lastIndex() : 0; - if (offset < 0 || offset > s.length()) { + if (offset < 0 || offset > s.size()) { setLastIndex(0); RETURN_RESULT(Encode::null()); } @@ -168,7 +168,7 @@ ReturnedValue RegExpObject::builtinExec(ExecutionEngine *engine, const String *s int len = value()->captureCount(); array->arrayReserve(len); ScopedValue v(scope); - int strlen = s.length(); + int strlen = s.size(); for (int i = 0; i < len; ++i) { int start = matchOffsets[i * 2]; int end = matchOffsets[i * 2 + 1]; @@ -230,7 +230,7 @@ uint parseFlags(Scope &scope, const QV4::Value *f) if (scope.hasException()) return flags; QString str = s->toQString(); - for (int i = 0; i < str.length(); ++i) { + for (int i = 0; i < str.size(); ++i) { if (str.at(i) == QLatin1Char('g') && !(flags & CompiledData::RegExp::RegExp_Global)) { flags |= CompiledData::RegExp::RegExp_Global; } else if (str.at(i) == QLatin1Char('i') && !(flags & CompiledData::RegExp::RegExp_IgnoreCase)) { @@ -380,7 +380,7 @@ ReturnedValue RegExpPrototype::execFirstMatch(const FunctionObject *b, const Val QString s = str->toQString(); int offset = r->lastIndex(); - if (offset < 0 || offset > s.length()) { + if (offset < 0 || offset > s.size()) { r->setLastIndex(0); RETURN_RESULT(Encode::null()); } @@ -516,7 +516,7 @@ ReturnedValue RegExpPrototype::method_get_ignoreCase(const FunctionObject *f, co static int advanceStringIndex(int index, const QString &str, bool unicode) { if (unicode) { - if (index < str.length() - 1 && + if (index < str.size() - 1 && str.at(index).isHighSurrogate() && str.at(index + 1).isLowSurrogate()) ++index; @@ -605,7 +605,7 @@ ReturnedValue RegExpPrototype::method_replace(const FunctionObject *f, const Val if (scope.hasException()) return Encode::undefined(); - int lengthS = s->toQString().length(); + int lengthS = s->toQString().size(); ScopedString replaceValue(scope); ScopedFunctionObject replaceFunction(scope, (argc > 1 ? argv[1] : Value::undefinedValue())); @@ -657,7 +657,7 @@ ReturnedValue RegExpPrototype::method_replace(const FunctionObject *f, const Val if (scope.hasException()) return Encode::undefined(); QString m = matchString->toQString(); - int matchLength = m.length(); + int matchLength = m.size(); v = resultObject->get(scope.engine->id_index()); int position = v->toInt32(); position = qMax(qMin(position, lengthS), 0); @@ -784,7 +784,7 @@ ReturnedValue RegExpPrototype::method_split(const FunctionObject *f, const Value return A->asReturnedValue(); QString S = s->toQString(); - int size = S.length(); + int size = S.size(); if (size == 0) { ScopedValue z(scope, exec(scope.engine, splitter, s)); if (z->isNull()) |
