aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorKarsten Heimrich <karsten.heimrich@qt.io>2020-06-16 10:23:19 +0200
committerKarsten Heimrich <karsten.heimrich@qt.io>2020-06-16 22:46:16 +0200
commit1b10ce6a08edbc2ac7e8fd7e97e3fc691f2081df (patch)
tree34ab485d1dd9435369709b5e77c11af6dec78c22 /src/qml/jsruntime
parentb65eee039092fa664e781cdd98a4bb5e66815218 (diff)
Port QtDeclarative from QStringRef to QStringView
Task-number: QTBUG-84319 Change-Id: I2dcfb8a2db98282c7a1acdad1e6f4f949f26df15 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4executablecompilationunit.cpp4
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp2
-rw-r--r--src/qml/jsruntime/qv4globalobject.cpp2
-rw-r--r--src/qml/jsruntime/qv4object.cpp2
-rw-r--r--src/qml/jsruntime/qv4propertykey.cpp2
-rw-r--r--src/qml/jsruntime/qv4regexpobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp2
-rw-r--r--src/qml/jsruntime/qv4script.cpp2
-rw-r--r--src/qml/jsruntime/qv4stringobject.cpp16
-rw-r--r--src/qml/jsruntime/qv4symbol.cpp2
10 files changed, 19 insertions, 19 deletions
diff --git a/src/qml/jsruntime/qv4executablecompilationunit.cpp b/src/qml/jsruntime/qv4executablecompilationunit.cpp
index 4b0fe0f5f6..0535e5029f 100644
--- a/src/qml/jsruntime/qv4executablecompilationunit.cpp
+++ b/src/qml/jsruntime/qv4executablecompilationunit.cpp
@@ -839,8 +839,8 @@ QString ExecutableCompilationUnit::bindingValueAsString(const CompiledData::Bind
// This code must match that in the qsTr() implementation
const QString &path = fileName();
int lastSlash = path.lastIndexOf(QLatin1Char('/'));
- QStringRef context = (lastSlash > -1) ? path.midRef(lastSlash + 1, path.length() - lastSlash - 5)
- : QStringRef();
+ QStringView context = (lastSlash > -1) ? QStringView{path}.mid(lastSlash + 1, path.length() - lastSlash - 5)
+ : QStringView();
QByteArray contextUtf8 = context.toUtf8();
QByteArray comment = stringAt(translation.commentIndex).toUtf8();
QByteArray text = stringAt(translation.stringIndex).toUtf8();
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index cdb3b8942b..3f0a316af7 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -198,7 +198,7 @@ Heap::FunctionObject *FunctionObject::createBuiltinFunction(ExecutionEngine *eng
Scope scope(engine);
ScopedString name(scope, nameOrSymbol);
if (!name)
- name = engine->newString(QChar::fromLatin1('[') + nameOrSymbol->toQString().midRef(1) + QChar::fromLatin1(']'));
+ name = engine->newString(QChar::fromLatin1('[') + QStringView{nameOrSymbol->toQString()}.mid(1) + QChar::fromLatin1(']'));
ScopedFunctionObject function(scope, engine->memoryManager->allocate<FunctionObject>(engine->rootContext(), name, code));
function->defineReadonlyConfigurableProperty(engine->id_length(), Value::fromInt32(argumentCount));
diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp
index 7fa32da8aa..5295bb7232 100644
--- a/src/qml/jsruntime/qv4globalobject.cpp
+++ b/src/qml/jsruntime/qv4globalobject.cpp
@@ -304,7 +304,7 @@ static QString decode(const QString &input, DecodeMode decodeMode, bool *ok)
++r;
}
if (*r)
- output.append(input.midRef(start, i - start + 1));
+ output.append(QStringView{input}.mid(start, i - start + 1));
else
output.append(QChar(b));
} else {
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index 11e2efb64c..bc145f958d 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -177,7 +177,7 @@ void Object::defineAccessorProperty(StringOrSymbol *name, VTable::Call getter, V
ScopedProperty p(scope);
QString n = name->toQString();
if (n.at(0) == QLatin1Char('@'))
- n = QChar::fromLatin1('[') + n.midRef(1) + QChar::fromLatin1(']');
+ n = QChar::fromLatin1('[') + QStringView{n}.mid(1) + QChar::fromLatin1(']');
if (getter) {
ScopedString getName(scope, v4->newString(QString::fromLatin1("get ") + n));
p->setGetter(ScopedFunctionObject(scope, FunctionObject::createBuiltinFunction(v4, getName, getter, 0)));
diff --git a/src/qml/jsruntime/qv4propertykey.cpp b/src/qml/jsruntime/qv4propertykey.cpp
index 064d030b83..2479a6cc65 100644
--- a/src/qml/jsruntime/qv4propertykey.cpp
+++ b/src/qml/jsruntime/qv4propertykey.cpp
@@ -103,7 +103,7 @@ QV4::Heap::String *QV4::PropertyKey::asFunctionName(ExecutionEngine *engine, Fun
if (s->internalClass->vtable->isString)
n += s->toQString();
else if (str.length() > 1)
- n += QChar::fromLatin1('[') + str.midRef(1) + QChar::fromLatin1(']');
+ n += QChar::fromLatin1('[') + QStringView{str}.mid(1) + QChar::fromLatin1(']');
}
return engine->newString(n);
}
diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp
index c2171d7c0e..16b9295ab7 100644
--- a/src/qml/jsruntime/qv4regexpobject.cpp
+++ b/src/qml/jsruntime/qv4regexpobject.cpp
@@ -726,12 +726,12 @@ ReturnedValue RegExpPrototype::method_replace(const FunctionObject *f, const Val
if (scope.hasException())
return Encode::undefined();
if (position >= nextSourcePosition) {
- accumulatedResult += s->toQString().midRef(nextSourcePosition, position - nextSourcePosition) + replacement;
+ accumulatedResult += QStringView{s->toQString()}.mid(nextSourcePosition, position - nextSourcePosition) + replacement;
nextSourcePosition = position + matchLength;
}
}
if (nextSourcePosition < lengthS) {
- accumulatedResult += s->toQString().midRef(nextSourcePosition);
+ accumulatedResult += QStringView{s->toQString()}.mid(nextSourcePosition);
}
return scope.engine->newString(accumulatedResult)->asReturnedValue();
}
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 5fc94b9ddd..393f99dd8f 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -417,7 +417,7 @@ double RuntimeHelpers::stringToNumber(const QString &string)
if (string.length() > excessiveLength)
return qQNaN();
- const QStringRef s = QStringRef(&string).trimmed();
+ const QStringView s = QStringView(string).trimmed();
if (s.startsWith(QLatin1Char('0'))) {
int base = -1;
if (s.startsWith(QLatin1String("0x")) || s.startsWith(QLatin1String("0X")))
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp
index 7fa3544e5a..10250f6adc 100644
--- a/src/qml/jsruntime/qv4script.cpp
+++ b/src/qml/jsruntime/qv4script.cpp
@@ -96,7 +96,7 @@ void Script::parse()
if (sourceCode.startsWith(QLatin1String("function("))) {
static const int snippetLength = 70;
qWarning() << "Warning: Using function expressions as statements in scripts is not compliant with the ECMAScript specification:\n"
- << (sourceCode.leftRef(snippetLength) + QLatin1String("..."))
+ << (QStringView{sourceCode}.left(snippetLength) + QLatin1String("..."))
<< "\nThis will throw a syntax error in Qt 5.12. If you want a function expression, surround it by parentheses.";
}
diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp
index bf098fef26..97a8941fe1 100644
--- a/src/qml/jsruntime/qv4stringobject.cpp
+++ b/src/qml/jsruntime/qv4stringobject.cpp
@@ -464,7 +464,7 @@ ReturnedValue StringPrototype::method_endsWith(const FunctionObject *b, const Va
if (pos == value.length())
RETURN_RESULT(Encode(value.endsWith(searchString)));
- QStringRef stringToSearch = value.leftRef(pos);
+ QStringView stringToSearch = QStringView{value}.left(pos);
return Encode(stringToSearch.endsWith(searchString));
}
@@ -514,7 +514,7 @@ ReturnedValue StringPrototype::method_includes(const FunctionObject *b, const Va
if (pos == 0)
RETURN_RESULT(Encode(value.contains(searchString)));
- QStringRef stringToSearch = value.midRef(pos);
+ QStringView stringToSearch = QStringView{value}.mid(pos);
return Encode(stringToSearch.contains(searchString));
}
@@ -765,7 +765,7 @@ static void appendReplacementString(QString *result, const QString &input, const
}
i += skip;
if (substStart != JSC::Yarr::offsetNoMatch && substEnd != JSC::Yarr::offsetNoMatch)
- *result += input.midRef(substStart, substEnd - substStart);
+ *result += QStringView{input}.mid(substStart, substEnd - substStart);
else if (skip == 0) // invalid capture reference. Taken as literal value
*result += replaceValue.at(i);
} else {
@@ -863,11 +863,11 @@ ReturnedValue StringPrototype::method_replace(const FunctionObject *b, const Val
Value that = Value::undefinedValue();
replacement = searchCallback->call(&that, arguments, numCaptures + 2);
CHECK_EXCEPTION();
- result += string.midRef(lastEnd, matchStart - lastEnd);
+ result += QStringView{string}.mid(lastEnd, matchStart - lastEnd);
result += replacement->toQString();
lastEnd = matchEnd;
}
- result += string.midRef(lastEnd);
+ result += QStringView{string}.mid(lastEnd);
} else {
QString newString = replaceValue->toQString();
result.reserve(string.length() + numStringMatches*newString.size());
@@ -880,11 +880,11 @@ ReturnedValue StringPrototype::method_replace(const FunctionObject *b, const Val
if (matchStart == JSC::Yarr::offsetNoMatch)
continue;
- result += string.midRef(lastEnd, matchStart - lastEnd);
+ result += QStringView{string}.mid(lastEnd, matchStart - lastEnd);
appendReplacementString(&result, string, newString, matchOffsets + baseIndex, numCaptures);
lastEnd = matchEnd;
}
- result += string.midRef(lastEnd);
+ result += QStringView{string}.mid(lastEnd);
}
if (matchOffsets != _matchOffsets)
@@ -1052,7 +1052,7 @@ ReturnedValue StringPrototype::method_startsWith(const FunctionObject *b, const
if (pos == 0)
return Encode(value.startsWith(searchString));
- QStringRef stringToSearch = value.midRef(pos);
+ QStringView stringToSearch = QStringView{value}.mid(pos);
RETURN_RESULT(Encode(stringToSearch.startsWith(searchString)));
}
diff --git a/src/qml/jsruntime/qv4symbol.cpp b/src/qml/jsruntime/qv4symbol.cpp
index be6d821c14..ec25b07fba 100644
--- a/src/qml/jsruntime/qv4symbol.cpp
+++ b/src/qml/jsruntime/qv4symbol.cpp
@@ -182,5 +182,5 @@ Heap::Symbol *Symbol::create(ExecutionEngine *e, const QString &s)
QString Symbol::descriptiveString() const
{
- return QLatin1String("Symbol(") + toQString().midRef(1) + QLatin1String(")");
+ return QLatin1String("Symbol(") + QStringView{toQString()}.mid(1) + QLatin1String(")");
}