aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--src/imports/wavefrontmesh/qwavefrontmesh.cpp10
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp2
-rw-r--r--src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp4
-rw-r--r--src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp4
-rw-r--r--src/qml/common/qqmljsmemorypool_p.h4
-rw-r--r--src/qml/compiler/qqmlirbuilder.cpp36
-rw-r--r--src/qml/compiler/qqmlirbuilder_p.h12
-rw-r--r--src/qml/compiler/qv4codegen.cpp6
-rw-r--r--src/qml/compiler/qv4codegen_p.h6
-rw-r--r--src/qml/compiler/qv4compilerscanfunctions.cpp8
-rw-r--r--src/qml/compiler/qv4compilerscanfunctions_p.h2
-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
-rw-r--r--src/qml/parser/qqmljs.g36
-rw-r--r--src/qml/parser/qqmljsast_p.h146
-rw-r--r--src/qml/parser/qqmljsengine_p.cpp9
-rw-r--r--src/qml/parser/qqmljsengine_p.h8
-rw-r--r--src/qml/parser/qqmljslexer.cpp8
-rw-r--r--src/qml/parser/qqmljslexer_p.h8
-rw-r--r--src/qml/qml/ftw/qhashedstring_p.h4
-rw-r--r--src/qml/qml/ftw/qstringhash_p.h4
-rw-r--r--src/qml/qml/qqmlerror.cpp4
-rw-r--r--src/qml/qml/qqmlfile.cpp4
-rw-r--r--src/qml/qml/qqmlimport.cpp14
-rw-r--r--src/qml/qml/qqmlinfo.h2
-rw-r--r--src/qml/qml/qqmlmetatype.cpp2
-rw-r--r--src/qml/qml/qqmlproperty.cpp12
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp8
-rw-r--r--src/qml/qml/qqmlpropertycache_p.h4
-rw-r--r--src/qml/qml/qqmlpropertycachecreator.cpp2
-rw-r--r--src/qml/qml/qqmlstringconverters.cpp16
-rw-r--r--src/qml/qml/qqmltype.cpp2
-rw-r--r--src/qml/qml/qqmltype_p.h2
-rw-r--r--src/qml/qml/qqmltypecompiler.cpp22
-rw-r--r--src/qml/qml/qqmltypecompiler_p.h8
-rw-r--r--src/qml/qml/qqmltypedata.cpp6
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp2
-rw-r--r--src/qml/qmldirparser/qqmldirparser.cpp6
-rw-r--r--src/qml/qmldirparser/qqmlimportresolver.cpp6
-rw-r--r--src/qml/qmldirparser/qqmlimportresolver_p.h2
-rw-r--r--src/qmlmodels/qqmldelegatemodel.cpp2
-rw-r--r--src/qmltest/quicktest.cpp2
-rw-r--r--src/quick/items/context2d/qquickcanvasitem.cpp2
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp22
-rw-r--r--src/quick/items/qquickpathview.cpp2
-rw-r--r--src/quick/items/qquickscalegrid.cpp8
-rw-r--r--src/quick/items/qquickscalegrid_p_p.h2
-rw-r--r--src/quick/items/qquicktextcontrol.cpp2
-rw-r--r--src/quick/items/qquicktextinput.cpp10
-rw-r--r--src/quick/util/qquickanimation.cpp2
-rw-r--r--src/quick/util/qquickglobal.cpp28
-rw-r--r--src/quick/util/qquickstategroup.cpp12
-rw-r--r--src/quick/util/qquickstyledtext.cpp44
-rw-r--r--tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp4
-rw-r--r--tests/auto/qml/qqmlparser/tst_qqmlparser.cpp14
-rw-r--r--tests/auto/shared/qqmljsastdumper.cpp2
-rw-r--r--tests/auto/shared/qqmljsastdumper.h2
-rw-r--r--tools/qmlcachegen/resourcefilter.cpp2
-rw-r--r--tools/qmleasing/splineeditor.cpp4
-rw-r--r--tools/qmlimportscanner/main.cpp2
-rw-r--r--tools/qmllint/checkidentifiers.cpp18
-rw-r--r--tools/qmllint/findwarnings.cpp6
-rw-r--r--tools/qmllint/findwarnings.h2
-rw-r--r--tools/qmlprofiler/qmlprofilerapplication.cpp2
-rw-r--r--tools/qmlprofiler/qmlprofilerdata.cpp4
-rw-r--r--tools/shared/componentversion.cpp4
74 files changed, 341 insertions, 342 deletions
diff --git a/src/imports/wavefrontmesh/qwavefrontmesh.cpp b/src/imports/wavefrontmesh/qwavefrontmesh.cpp
index 1772c40c50..5d1affbdab 100644
--- a/src/imports/wavefrontmesh/qwavefrontmesh.cpp
+++ b/src/imports/wavefrontmesh/qwavefrontmesh.cpp
@@ -257,7 +257,7 @@ void QWavefrontMesh::readData()
while (!stream.atEnd()) {
stream.readLineInto(&buffer);
- QVector<QStringRef> tokens = buffer.splitRef(space, Qt::SkipEmptyParts);
+ auto tokens = QStringView{buffer}.split(space, Qt::SkipEmptyParts);
if (tokens.size() < 2)
continue;
@@ -316,7 +316,7 @@ void QWavefrontMesh::readData()
if (tokens.size() >= 4 && tokens.size() <= 5) {
{
bool ok;
- QVector<QStringRef> faceTokens = tokens.at(1).split(slash, Qt::SkipEmptyParts);
+ auto faceTokens = tokens.at(1).split(slash, Qt::SkipEmptyParts);
Q_ASSERT(!faceTokens.isEmpty());
p1 = faceTokens.at(0).toInt(&ok) - 1;
@@ -336,7 +336,7 @@ void QWavefrontMesh::readData()
{
bool ok;
- QVector<QStringRef> faceTokens = tokens.at(2).split(slash, Qt::SkipEmptyParts);
+ auto faceTokens = tokens.at(2).split(slash, Qt::SkipEmptyParts);
Q_ASSERT(!faceTokens.isEmpty());
p2 = faceTokens.at(0).toInt(&ok) - 1;
@@ -356,7 +356,7 @@ void QWavefrontMesh::readData()
{
bool ok;
- QVector<QStringRef> faceTokens = tokens.at(3).split(slash, Qt::SkipEmptyParts);
+ auto faceTokens = tokens.at(3).split(slash, Qt::SkipEmptyParts);
Q_ASSERT(!faceTokens.isEmpty());
p3 = faceTokens.at(0).toInt(&ok) - 1;
@@ -394,7 +394,7 @@ void QWavefrontMesh::readData()
if (tokens.size() == 5) {
bool ok;
- QVector<QStringRef> faceTokens = tokens.at(4).split(slash, Qt::SkipEmptyParts);
+ auto faceTokens = tokens.at(4).split(slash, Qt::SkipEmptyParts);
Q_ASSERT(!faceTokens.isEmpty());
int p4 = faceTokens.at(0).toInt(&ok) - 1;
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp
index 223c575701..3cf0de74d1 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp
@@ -722,7 +722,7 @@ bool QQmlEngineDebugServiceImpl::resetBinding(int objectId, const QString &prope
QQmlContext *context = qmlContext(object);
if (object && context && context->isValid()) {
- QStringRef parentPropertyRef(&propertyName);
+ QStringView parentPropertyRef(propertyName);
const int idx = parentPropertyRef.indexOf(QLatin1Char('.'));
if (idx != -1)
parentPropertyRef = parentPropertyRef.left(idx);
diff --git a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp
index c504ea605a..09baa73f7d 100644
--- a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp
+++ b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp
@@ -183,9 +183,9 @@ QQmlNativeDebugConnector::QQmlNativeDebugConnector()
: m_blockingMode(false)
{
const QString args = commandLineArguments();
- const auto lstjsDebugArguments = args.splitRef(QLatin1Char(','), Qt::SkipEmptyParts);
+ const auto lstjsDebugArguments = QStringView{args}.split(QLatin1Char(','), Qt::SkipEmptyParts);
QStringList services;
- for (const QStringRef &strArgument : lstjsDebugArguments) {
+ for (const QStringView &strArgument : lstjsDebugArguments) {
if (strArgument == QLatin1String("block")) {
m_blockingMode = true;
} else if (strArgument == QLatin1String("native")) {
diff --git a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
index 4d68a4508b..13d5292eb2 100644
--- a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
+++ b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
@@ -345,9 +345,9 @@ void QQmlDebugServerImpl::parseArguments()
QString fileName;
QStringList services;
- const auto lstjsDebugArguments = args.splitRef(QLatin1Char(','), Qt::SkipEmptyParts);
+ const auto lstjsDebugArguments = QStringView{args}.split(QLatin1Char(','), Qt::SkipEmptyParts);
for (auto argsIt = lstjsDebugArguments.begin(), argsItEnd = lstjsDebugArguments.end(); argsIt != argsItEnd; ++argsIt) {
- const QStringRef &strArgument = *argsIt;
+ const QStringView &strArgument = *argsIt;
if (strArgument.startsWith(QLatin1String("port:"))) {
portFrom = strArgument.mid(5).toInt(&ok);
portTo = portFrom;
diff --git a/src/qml/common/qqmljsmemorypool_p.h b/src/qml/common/qqmljsmemorypool_p.h
index 0cf7ea84e6..dcf3fafb67 100644
--- a/src/qml/common/qqmljsmemorypool_p.h
+++ b/src/qml/common/qqmljsmemorypool_p.h
@@ -105,9 +105,9 @@ public:
template <typename Tp, typename... Ta> Tp *New(Ta... args)
{ return new (this->allocate(sizeof(Tp))) Tp(args...); }
- QStringRef newString(const QString &string) {
+ QStringView newString(const QString &string) {
strings.append(new QString(string));
- return QStringRef(strings.last());
+ return QStringView(*strings.last());
}
private:
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp
index bc979a81e0..8ea97ab956 100644
--- a/src/qml/compiler/qqmlirbuilder.cpp
+++ b/src/qml/compiler/qqmlirbuilder.cpp
@@ -407,7 +407,7 @@ void ScriptDirectivesCollector::importModule(const QString &uri, const QString &
QV4::CompiledData::Import *import = engine->pool()->New<QV4::CompiledData::Import>();
import->type = QV4::CompiledData::Import::ImportLibrary;
import->uriIndex = jsGenerator->registerString(uri);
- import->version = IRBuilder::extractVersion(QStringRef(&version));
+ import->version = IRBuilder::extractVersion(QStringView(version));
import->qualifierIndex = jsGenerator->registerString(module);
import->location.line = lineNumber;
import->location.column = column;
@@ -526,7 +526,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiObjectDefinition *node)
QQmlJS::AST::UiQualifiedId *lastId = node->qualifiedTypeNameId;
while (lastId->next)
lastId = lastId->next;
- bool isType = lastId->name.unicode()->isUpper();
+ bool isType = lastId->name.data()->isUpper();
if (isType) {
int idx = 0;
if (!defineQMLObject(&idx, node))
@@ -915,7 +915,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node)
if (memberType == QLatin1String("alias")) {
return appendAlias(node);
} else {
- const QStringRef &name = node->name;
+ const QStringView &name = node->name;
Property *property = New<Property>();
property->isReadOnly = node->isReadonlyMember;
@@ -927,7 +927,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node)
property->setBuiltinType(builtinPropertyType);
if (!typeFound && memberType.at(0).isUpper()) {
- const QStringRef &typeModifier = node->typeModifier;
+ const QStringView &typeModifier = node->typeModifier;
property->setCustomType(registerString(memberType));
if (typeModifier == QLatin1String("list")) {
@@ -1043,15 +1043,15 @@ QString IRBuilder::asString(QQmlJS::AST::UiQualifiedId *node)
return s;
}
-QStringRef IRBuilder::asStringRef(QQmlJS::AST::Node *node)
+QStringView IRBuilder::asStringRef(QQmlJS::AST::Node *node)
{
if (!node)
- return QStringRef();
+ return QStringView();
return textRefAt(node->firstSourceLocation(), node->lastSourceLocation());
}
-QTypeRevision IRBuilder::extractVersion(const QStringRef &string)
+QTypeRevision IRBuilder::extractVersion(QStringView string)
{
if (string.isEmpty())
return QTypeRevision();
@@ -1062,9 +1062,9 @@ QTypeRevision IRBuilder::extractVersion(const QStringRef &string)
: QTypeRevision::fromVersion(string.left(dot).toInt(), string.mid(dot + 1).toInt());
}
-QStringRef IRBuilder::textRefAt(const QQmlJS::SourceLocation &first, const QQmlJS::SourceLocation &last) const
+QStringView IRBuilder::textRefAt(const QQmlJS::SourceLocation &first, const QQmlJS::SourceLocation &last) const
{
- return QStringRef(&sourceCode, first.offset, last.offset + last.length - first.offset);
+ return QStringView(sourceCode).mid(first.offset, last.offset + last.length - first.offset);
}
void IRBuilder::setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST::Statement *statement, QQmlJS::AST::Node *parentNode)
@@ -1127,7 +1127,7 @@ void IRBuilder::setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST
}
}
-void IRBuilder::tryGeneratingTranslationBinding(const QStringRef &base, AST::ArgumentList *args, QV4::CompiledData::Binding *binding)
+void IRBuilder::tryGeneratingTranslationBinding(QStringView base, AST::ArgumentList *args, QV4::CompiledData::Binding *binding)
{
if (base == QLatin1String("qsTr")) {
QV4::CompiledData::TranslationData translationData;
@@ -1138,7 +1138,7 @@ void IRBuilder::tryGeneratingTranslationBinding(const QStringRef &base, AST::Arg
if (!args || !args->expression)
return; // no arguments, stop
- QStringRef translation;
+ QStringView translation;
if (QQmlJS::AST::StringLiteral *arg1 = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(args->expression)) {
translation = arg1->value;
} else {
@@ -1179,7 +1179,7 @@ void IRBuilder::tryGeneratingTranslationBinding(const QStringRef &base, AST::Arg
if (!args || !args->expression)
return; // no arguments, stop
- QStringRef id;
+ QStringView id;
if (QQmlJS::AST::StringLiteral *arg1 = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(args->expression)) {
id = arg1->value;
} else {
@@ -1207,7 +1207,7 @@ void IRBuilder::tryGeneratingTranslationBinding(const QStringRef &base, AST::Arg
if (!args || !args->expression)
return; // no arguments, stop
- QStringRef str;
+ QStringView str;
if (QQmlJS::AST::StringLiteral *arg1 = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(args->expression)) {
str = arg1->value;
} else {
@@ -1228,7 +1228,7 @@ void IRBuilder::tryGeneratingTranslationBinding(const QStringRef &base, AST::Arg
if (!args || !args->expression)
return; // no second arguments, stop
- QStringRef str;
+ QStringView str;
if (QQmlJS::AST::StringLiteral *arg2 = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(args->expression)) {
str = arg2->value;
} else {
@@ -1408,7 +1408,7 @@ Object *IRBuilder::bindingsTarget() const
bool IRBuilder::setId(const QQmlJS::SourceLocation &idLocation, QQmlJS::AST::Statement *value)
{
QQmlJS::SourceLocation loc = value->firstSourceLocation();
- QStringRef str;
+ QStringView str;
QQmlJS::AST::Node *node = value;
if (QQmlJS::AST::ExpressionStatement *stmt = QQmlJS::AST::cast<QQmlJS::AST::ExpressionStatement *>(node)) {
@@ -1433,7 +1433,7 @@ bool IRBuilder::setId(const QQmlJS::SourceLocation &idLocation, QQmlJS::AST::Sta
if (!ch.isLetter() && ch != u)
COMPILE_EXCEPTION(loc, tr( "IDs must start with a letter or underscore"));
- for (int ii = 1; ii < str.count(); ++ii) {
+ for (int ii = 1; ii < str.size(); ++ii) {
ch = str.at(ii);
if (!ch.isLetterOrNumber() && ch != u)
COMPILE_EXCEPTION(loc, tr( "IDs must contain only letters, numbers, and underscores"));
@@ -1469,7 +1469,7 @@ bool IRBuilder::resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, O
qualifiedIdElement = qualifiedIdElement->next;
currentName += QLatin1Char('.') + qualifiedIdElement->name;
- if (!qualifiedIdElement->name.unicode()->isUpper())
+ if (!qualifiedIdElement->name.data()->isUpper())
COMPILE_EXCEPTION(qualifiedIdElement->firstSourceLocation(), tr("Expected type name"));
break;
@@ -1479,7 +1479,7 @@ bool IRBuilder::resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, O
*object = _object;
while (qualifiedIdElement->next) {
const quint32 propertyNameIndex = registerString(currentName);
- const bool isAttachedProperty = qualifiedIdElement->name.unicode()->isUpper();
+ const bool isAttachedProperty = qualifiedIdElement->name.data()->isUpper();
Binding *binding = (*object)->findBinding(propertyNameIndex);
if (binding) {
diff --git a/src/qml/compiler/qqmlirbuilder_p.h b/src/qml/compiler/qqmlirbuilder_p.h
index 254d21001b..7e6c8c1272 100644
--- a/src/qml/compiler/qqmlirbuilder_p.h
+++ b/src/qml/compiler/qqmlirbuilder_p.h
@@ -497,16 +497,16 @@ public:
{ return defineQMLObject(objectIndex, node->qualifiedTypeNameId, node->qualifiedTypeNameId->firstSourceLocation(), node->initializer, declarationsOverride); }
static QString asString(QQmlJS::AST::UiQualifiedId *node);
- QStringRef asStringRef(QQmlJS::AST::Node *node);
- static QTypeRevision extractVersion(const QStringRef &string);
- QStringRef textRefAt(const QQmlJS::SourceLocation &loc) const
- { return QStringRef(&sourceCode, loc.offset, loc.length); }
- QStringRef textRefAt(const QQmlJS::SourceLocation &first,
+ QStringView asStringRef(QQmlJS::AST::Node *node);
+ static QTypeRevision extractVersion(QStringView string);
+ QStringView textRefAt(const QQmlJS::SourceLocation &loc) const
+ { return QStringView(sourceCode).mid(loc.offset, loc.length); }
+ QStringView textRefAt(const QQmlJS::SourceLocation &first,
const QQmlJS::SourceLocation &last) const;
void setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST::Statement *statement,
QQmlJS::AST::Node *parentNode);
- void tryGeneratingTranslationBinding(const QStringRef &base, QQmlJS::AST::ArgumentList *args, QV4::CompiledData::Binding *binding);
+ void tryGeneratingTranslationBinding(QStringView base, QQmlJS::AST::ArgumentList *args, QV4::CompiledData::Binding *binding);
void appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Statement *value,
QQmlJS::AST::Node *parentNode);
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 4588690307..f642797761 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -3969,14 +3969,14 @@ public:
}
private:
- void collectIdentifiers(QVector<QStringView> &ids, AST::Node *node) {
+ void collectIdentifiers(QList<QStringView> &ids, AST::Node *node) {
class Collector: public QQmlJS::AST::Visitor {
private:
- QVector<QStringView> &ids;
+ QList<QStringView> &ids;
VolatileMemoryLocationScanner *parent;
public:
- Collector(QVector<QStringView> &ids, VolatileMemoryLocationScanner *parent) :
+ Collector(QList<QStringView> &ids, VolatileMemoryLocationScanner *parent) :
QQmlJS::AST::Visitor(parent->recursionDepth()), ids(ids), parent(parent)
{}
diff --git a/src/qml/compiler/qv4codegen_p.h b/src/qml/compiler/qv4codegen_p.h
index 255698d790..e7d7a21294 100644
--- a/src/qml/compiler/qv4codegen_p.h
+++ b/src/qml/compiler/qv4codegen_p.h
@@ -105,15 +105,15 @@ public:
class VolatileMemoryLocations {
friend VolatileMemoryLocationScanner;
bool allVolatile = false;
- QVector<QStringView> specificLocations;
+ QList<QStringView> specificLocations;
public:
- bool isVolatile(const QStringView &name) {
+ bool isVolatile(QStringView name) {
if (allVolatile)
return true;
return specificLocations.contains(name);
}
- void add(const QStringRef &name) { if (!allVolatile) specificLocations.append(name); }
+ void add(QStringView name) { if (!allVolatile) specificLocations.append(name); }
void setAllVolatile() { allVolatile = true; }
};
class RValue {
diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp
index a1ddee8234..4c8f0d0658 100644
--- a/src/qml/compiler/qv4compilerscanfunctions.cpp
+++ b/src/qml/compiler/qv4compilerscanfunctions.cpp
@@ -115,7 +115,7 @@ void ScanFunctions::checkDirectivePrologue(StatementList *ast)
// allowed.
if (strLit->literalToken.length < 2)
continue;
- QStringRef str = _sourceCode.midRef(strLit->literalToken.offset + 1, strLit->literalToken.length - 2);
+ QStringView str = QStringView{_sourceCode}.mid(strLit->literalToken.offset + 1, strLit->literalToken.length - 2);
if (str == QLatin1String("use strict")) {
_context->isStrict = true;
} else {
@@ -129,7 +129,7 @@ void ScanFunctions::checkDirectivePrologue(StatementList *ast)
}
}
-void ScanFunctions::checkName(const QStringRef &name, const QQmlJS::SourceLocation &loc)
+void ScanFunctions::checkName(QStringView name, const QQmlJS::SourceLocation &loc)
{
if (_context->isStrict) {
if (name == QLatin1String("implements")
@@ -337,7 +337,7 @@ bool ScanFunctions::visit(PatternElement *ast)
for (const auto &name : qAsConst(names)) {
if (_context->isStrict && (name.id == QLatin1String("eval") || name.id == QLatin1String("arguments")))
_cg->throwSyntaxError(ast->identifierToken, QStringLiteral("Variable name may not be eval or arguments in strict mode"));
- checkName(QStringRef(&name.id), ast->identifierToken);
+ checkName(QStringView(name.id), ast->identifierToken);
if (name.id == QLatin1String("arguments"))
_context->usesArgumentsObject = Context::ArgumentsObjectNotUsed;
if (ast->scope == VariableScope::Const && !ast->initializer && !ast->isForDeclaration && !ast->destructuringPattern()) {
@@ -376,7 +376,7 @@ bool ScanFunctions::visit(ExpressionStatement *ast)
return false;
} else {
SourceLocation firstToken = ast->firstSourceLocation();
- if (_sourceCode.midRef(firstToken.offset, firstToken.length) == QLatin1String("function")) {
+ if (QStringView{_sourceCode}.mid(firstToken.offset, firstToken.length) == QLatin1String("function")) {
_cg->throwSyntaxError(firstToken, QStringLiteral("unexpected token"));
}
}
diff --git a/src/qml/compiler/qv4compilerscanfunctions_p.h b/src/qml/compiler/qv4compilerscanfunctions_p.h
index e39aa2454e..0336398cac 100644
--- a/src/qml/compiler/qv4compilerscanfunctions_p.h
+++ b/src/qml/compiler/qv4compilerscanfunctions_p.h
@@ -97,7 +97,7 @@ protected:
void checkDirectivePrologue(QQmlJS::AST::StatementList *ast);
- void checkName(const QStringRef &name, const QQmlJS::SourceLocation &loc);
+ void checkName(QStringView name, const QQmlJS::SourceLocation &loc);
bool visit(QQmlJS::AST::Program *ast) override;
void endVisit(QQmlJS::AST::Program *) override;
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(")");
}
diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g
index 8d79e48287..783ac273c8 100644
--- a/src/qml/parser/qqmljs.g
+++ b/src/qml/parser/qqmljs.g
@@ -403,10 +403,10 @@ protected:
inline Value &sym(int index)
{ return sym_stack [tos + index - 1]; }
- inline QStringRef &stringRef(int index)
+ inline QStringView &stringRef(int index)
{ return string_stack [tos + index - 1]; }
- inline QStringRef &rawStringRef(int index)
+ inline QStringView &rawStringRef(int index)
{ return rawString_stack [tos + index - 1]; }
inline SourceLocation &loc(int index)
@@ -444,8 +444,8 @@ protected:
Value *sym_stack = nullptr;
int *state_stack = nullptr;
SourceLocation *location_stack = nullptr;
- QVector<QStringRef> string_stack;
- QVector<QStringRef> rawString_stack;
+ QList<QStringView> string_stack;
+ QList<QStringView> rawString_stack;
AST::Node *program = nullptr;
@@ -456,14 +456,14 @@ protected:
int token;
double dval;
SourceLocation loc;
- QStringRef spell;
- QStringRef raw;
+ QStringView spell;
+ QStringView raw;
};
int yytoken = -1;
double yylval = 0.;
- QStringRef yytokenspell;
- QStringRef yytokenraw;
+ QStringView yytokenspell;
+ QStringView yytokenraw;
SourceLocation yylloc;
SourceLocation yyprevlloc;
@@ -555,7 +555,7 @@ static inline SourceLocation location(Lexer *lexer)
AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
{
- QVarLengthArray<QStringRef, 4> nameIds;
+ QVarLengthArray<QStringView, 4> nameIds;
QVarLengthArray<SourceLocation, 4> locations;
AST::ExpressionNode *it = expr;
@@ -3613,7 +3613,7 @@ ContinueStatement: T_CONTINUE IdentifierReference Semicolon;
BreakStatement: T_BREAK Semicolon;
/.
case $rule_number: {
- AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringRef());
+ AST::BreakStatement *node = new (pool) AST::BreakStatement(QStringView());
node->breakToken = loc(1);
node->semicolonToken = loc(2);
sym(1).Node = node;
@@ -3887,7 +3887,7 @@ FunctionDeclaration_Default: Function T_LPAREN FormalParameters T_RPAREN TypeAnn
case $rule_number: {
if (!ensureNoFunctionTypeAnnotations(sym(5).TypeAnnotation, sym(3).FormalParameterList))
return false;
- AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(QStringRef(), sym(3).FormalParameterList, sym(7).StatementList,
+ AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(QStringView(), sym(3).FormalParameterList, sym(7).StatementList,
/*type annotation*/nullptr);
node->functionToken = loc(1);
node->lparenToken = loc(2);
@@ -3921,7 +3921,7 @@ FunctionExpression: T_FUNCTION T_LPAREN FormalParameters T_RPAREN TypeAnnotation
case $rule_number: {
if (!ensureNoFunctionTypeAnnotations(sym(5).TypeAnnotation, sym(3).FormalParameterList))
return false;
- AST::FunctionExpression *node = new (pool) AST::FunctionExpression(QStringRef(), sym(3).FormalParameterList, sym(7).StatementList,
+ AST::FunctionExpression *node = new (pool) AST::FunctionExpression(QStringView(), sym(3).FormalParameterList, sym(7).StatementList,
/*type annotation*/nullptr);
node->functionToken = loc(1);
node->lparenToken = loc(2);
@@ -4011,7 +4011,7 @@ ArrowFunction_In: ArrowParameters T_ARROW ConciseBodyLookahead AssignmentExpress
ret->returnToken = sym(4).Node->firstSourceLocation();
ret->semicolonToken = sym(4).Node->lastSourceLocation();
AST::StatementList *statements = (new (pool) AST::StatementList(ret))->finish();
- AST::FunctionExpression *f = new (pool) AST::FunctionExpression(QStringRef(), sym(1).FormalParameterList, statements);
+ AST::FunctionExpression *f = new (pool) AST::FunctionExpression(QStringView(), sym(1).FormalParameterList, statements);
f->isArrowFunction = true;
f->functionToken = sym(1).Node ? sym(1).Node->firstSourceLocation() : loc(1);
f->lbraceToken = sym(4).Node->firstSourceLocation();
@@ -4025,7 +4025,7 @@ ArrowFunction: ArrowParameters T_ARROW ConciseBodyLookahead T_FORCE_BLOCK Functi
ArrowFunction_In: ArrowParameters T_ARROW ConciseBodyLookahead T_FORCE_BLOCK FunctionLBrace FunctionBody FunctionRBrace;
/.
case $rule_number: {
- AST::FunctionExpression *f = new (pool) AST::FunctionExpression(QStringRef(), sym(1).FormalParameterList, sym(6).StatementList);
+ AST::FunctionExpression *f = new (pool) AST::FunctionExpression(QStringView(), sym(1).FormalParameterList, sym(6).StatementList);
f->isArrowFunction = true;
f->functionToken = sym(1).Node ? sym(1).Node->firstSourceLocation() : loc(1);
f->lbraceToken = loc(6);
@@ -4186,7 +4186,7 @@ GeneratorDeclaration_Default: GeneratorDeclaration;
GeneratorDeclaration_Default: FunctionStar GeneratorLParen FormalParameters T_RPAREN FunctionLBrace GeneratorBody GeneratorRBrace;
/.
case $rule_number: {
- AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(QStringRef(), sym(3).FormalParameterList, sym(6).StatementList);
+ AST::FunctionDeclaration *node = new (pool) AST::FunctionDeclaration(QStringView(), sym(3).FormalParameterList, sym(6).StatementList);
node->functionToken = loc(1);
node->lparenToken = loc(2);
node->rparenToken = loc(4);
@@ -4216,7 +4216,7 @@ GeneratorExpression: T_FUNCTION_STAR BindingIdentifier GeneratorLParen FormalPar
GeneratorExpression: T_FUNCTION_STAR GeneratorLParen FormalParameters T_RPAREN FunctionLBrace GeneratorBody GeneratorRBrace;
/.
case $rule_number: {
- AST::FunctionExpression *node = new (pool) AST::FunctionExpression(QStringRef(), sym(3).FormalParameterList, sym(6).StatementList);
+ AST::FunctionExpression *node = new (pool) AST::FunctionExpression(QStringView(), sym(3).FormalParameterList, sym(6).StatementList);
node->functionToken = loc(1);
node->lparenToken = loc(2);
node->rparenToken = loc(4);
@@ -4291,7 +4291,7 @@ ClassExpression: T_CLASS BindingIdentifier ClassHeritageOpt ClassLBrace ClassBod
ClassDeclaration_Default: T_CLASS ClassHeritageOpt ClassLBrace ClassBodyOpt ClassRBrace;
/.
case $rule_number: {
- AST::ClassDeclaration *node = new (pool) AST::ClassDeclaration(QStringRef(), sym(2).Expression, sym(4).ClassElementList);
+ AST::ClassDeclaration *node = new (pool) AST::ClassDeclaration(QStringView(), sym(2).Expression, sym(4).ClassElementList);
node->classToken = loc(1);
node->lbraceToken = loc(3);
node->rbraceToken = loc(5);
@@ -4302,7 +4302,7 @@ ClassDeclaration_Default: T_CLASS ClassHeritageOpt ClassLBrace ClassBodyOpt Clas
ClassExpression: T_CLASS ClassHeritageOpt ClassLBrace ClassBodyOpt ClassRBrace;
/.
case $rule_number: {
- AST::ClassExpression *node = new (pool) AST::ClassExpression(QStringRef(), sym(2).Expression, sym(4).ClassElementList);
+ AST::ClassExpression *node = new (pool) AST::ClassExpression(QStringView(), sym(2).Expression, sym(4).ClassElementList);
node->classToken = loc(1);
node->lbraceToken = loc(3);
node->rbraceToken = loc(5);
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h
index 700643e1df..f846a5a3dc 100644
--- a/src/qml/parser/qqmljsast_p.h
+++ b/src/qml/parser/qqmljsast_p.h
@@ -335,11 +335,11 @@ class QML_PARSER_EXPORT UiQualifiedId: public Node
public:
QQMLJS_DECLARE_AST_NODE(UiQualifiedId)
- UiQualifiedId(const QStringRef &name)
+ UiQualifiedId(QStringView name)
: next(this), name(name)
{ kind = K; }
- UiQualifiedId(UiQualifiedId *previous, const QStringRef &name)
+ UiQualifiedId(UiQualifiedId *previous, QStringView name)
: name(name)
{
kind = K;
@@ -364,7 +364,7 @@ public:
// attributes
UiQualifiedId *next;
- QStringRef name;
+ QStringView name;
SourceLocation identifierToken;
};
@@ -549,7 +549,7 @@ class QML_PARSER_EXPORT IdentifierExpression: public LeftHandSideExpression
public:
QQMLJS_DECLARE_AST_NODE(IdentifierExpression)
- IdentifierExpression(const QStringRef &n):
+ IdentifierExpression(QStringView n):
name (n) { kind = K; }
void accept0(BaseVisitor *visitor) override;
@@ -561,7 +561,7 @@ public:
{ return identifierToken; }
// attributes
- QStringRef name;
+ QStringView name;
SourceLocation identifierToken;
};
@@ -698,7 +698,7 @@ class QML_PARSER_EXPORT StringLiteral : public LeftHandSideExpression
public:
QQMLJS_DECLARE_AST_NODE(StringLiteral)
- StringLiteral(const QStringRef &v):
+ StringLiteral(QStringView v):
value (v) { kind = K; }
void accept0(BaseVisitor *visitor) override;
@@ -710,7 +710,7 @@ public:
{ return literalToken; }
// attributes:
- QStringRef value;
+ QStringView value;
SourceLocation literalToken;
};
@@ -719,7 +719,7 @@ class QML_PARSER_EXPORT TemplateLiteral : public LeftHandSideExpression
public:
QQMLJS_DECLARE_AST_NODE(TemplateLiteral)
- TemplateLiteral(const QStringRef &str, const QStringRef &raw, ExpressionNode *e)
+ TemplateLiteral(QStringView str, QStringView raw, ExpressionNode *e)
: value(str), rawValue(raw), expression(e), next(nullptr)
{ kind = K; }
@@ -734,8 +734,8 @@ public:
void accept0(BaseVisitor *visitor) override;
- QStringRef value;
- QStringRef rawValue;
+ QStringView value;
+ QStringView rawValue;
ExpressionNode *expression;
TemplateLiteral *next;
SourceLocation literalToken;
@@ -746,7 +746,7 @@ class QML_PARSER_EXPORT RegExpLiteral: public LeftHandSideExpression
public:
QQMLJS_DECLARE_AST_NODE(RegExpLiteral)
- RegExpLiteral(const QStringRef &p, int f):
+ RegExpLiteral(QStringView p, int f):
pattern (p), flags (f) { kind = K; }
void accept0(BaseVisitor *visitor) override;
@@ -758,7 +758,7 @@ public:
{ return literalToken; }
// attributes:
- QStringRef pattern;
+ QStringView pattern;
int flags;
SourceLocation literalToken;
};
@@ -937,7 +937,7 @@ public:
: initializer(i), type(t)
{ kind = K; }
- PatternElement(const QStringRef &n, TypeAnnotation *typeAnnotation = nullptr, ExpressionNode *i = nullptr, Type t = Binding)
+ PatternElement(QStringView n, TypeAnnotation *typeAnnotation = nullptr, ExpressionNode *i = nullptr, Type t = Binding)
: bindingIdentifier(n), initializer(i), type(t)
, typeAnnotation(typeAnnotation)
{
@@ -973,7 +973,7 @@ public:
// attributes
SourceLocation identifierToken;
- QStringRef bindingIdentifier;
+ QStringView bindingIdentifier;
ExpressionNode *bindingTarget = nullptr;
ExpressionNode *initializer = nullptr;
Type type = Literal;
@@ -1032,7 +1032,7 @@ public:
: PatternElement(i, t), name(name)
{ kind = K; }
- PatternProperty(PropertyName *name, const QStringRef &n, ExpressionNode *i = nullptr)
+ PatternProperty(PropertyName *name, QStringView n, ExpressionNode *i = nullptr)
: PatternElement(n, /*type annotation*/nullptr, i), name(name)
{ kind = K; }
@@ -1102,7 +1102,7 @@ class QML_PARSER_EXPORT IdentifierPropertyName: public PropertyName
public:
QQMLJS_DECLARE_AST_NODE(IdentifierPropertyName)
- IdentifierPropertyName(const QStringRef &n):
+ IdentifierPropertyName(QStringView n):
id (n) { kind = K; }
void accept0(BaseVisitor *visitor) override;
@@ -1110,7 +1110,7 @@ public:
QString asString() const override { return id.toString(); }
// attributes
- QStringRef id;
+ QStringView id;
};
class QML_PARSER_EXPORT StringLiteralPropertyName: public PropertyName
@@ -1118,7 +1118,7 @@ class QML_PARSER_EXPORT StringLiteralPropertyName: public PropertyName
public:
QQMLJS_DECLARE_AST_NODE(StringLiteralPropertyName)
- StringLiteralPropertyName(const QStringRef &n):
+ StringLiteralPropertyName(QStringView n):
id (n) { kind = K; }
void accept0(BaseVisitor *visitor) override;
@@ -1126,7 +1126,7 @@ public:
QString asString() const override { return id.toString(); }
// attributes
- QStringRef id;
+ QStringView id;
};
class QML_PARSER_EXPORT NumericLiteralPropertyName: public PropertyName
@@ -1198,7 +1198,7 @@ class QML_PARSER_EXPORT FieldMemberExpression: public LeftHandSideExpression
public:
QQMLJS_DECLARE_AST_NODE(FieldMemberExpression)
- FieldMemberExpression(ExpressionNode *b, const QStringRef &n):
+ FieldMemberExpression(ExpressionNode *b, QStringView n):
base (b), name (n)
{ kind = K; }
@@ -1212,7 +1212,7 @@ public:
// attributes
ExpressionNode *base;
- QStringRef name;
+ QStringView name;
SourceLocation dotToken;
SourceLocation identifierToken;
};
@@ -1988,7 +1988,7 @@ class QML_PARSER_EXPORT ContinueStatement: public Statement
public:
QQMLJS_DECLARE_AST_NODE(ContinueStatement)
- ContinueStatement(const QStringRef &l = QStringRef()):
+ ContinueStatement(QStringView l = QStringView()):
label (l) { kind = K; }
void accept0(BaseVisitor *visitor) override;
@@ -2000,7 +2000,7 @@ public:
{ return semicolonToken; }
// attributes
- QStringRef label;
+ QStringView label;
SourceLocation continueToken;
SourceLocation identifierToken;
SourceLocation semicolonToken;
@@ -2011,7 +2011,7 @@ class QML_PARSER_EXPORT BreakStatement: public Statement
public:
QQMLJS_DECLARE_AST_NODE(BreakStatement)
- BreakStatement(const QStringRef &l):
+ BreakStatement(QStringView l):
label (l) { kind = K; }
void accept0(BaseVisitor *visitor) override;
@@ -2023,7 +2023,7 @@ public:
{ return semicolonToken; }
// attributes
- QStringRef label;
+ QStringView label;
SourceLocation breakToken;
SourceLocation identifierToken;
SourceLocation semicolonToken;
@@ -2239,7 +2239,7 @@ class QML_PARSER_EXPORT LabelledStatement: public Statement
public:
QQMLJS_DECLARE_AST_NODE(LabelledStatement)
- LabelledStatement(const QStringRef &l, Statement *stmt):
+ LabelledStatement(QStringView l, Statement *stmt):
label (l), statement (stmt)
{ kind = K; }
@@ -2252,7 +2252,7 @@ public:
{ return statement->lastSourceLocation(); }
// attributes
- QStringRef label;
+ QStringView label;
Statement *statement;
SourceLocation identifierToken;
SourceLocation colonToken;
@@ -2372,7 +2372,7 @@ class QML_PARSER_EXPORT FunctionExpression: public ExpressionNode
public:
QQMLJS_DECLARE_AST_NODE(FunctionExpression)
- FunctionExpression(const QStringRef &n, FormalParameterList *f, StatementList *b, TypeAnnotation *typeAnnotation = nullptr):
+ FunctionExpression(QStringView n, FormalParameterList *f, StatementList *b, TypeAnnotation *typeAnnotation = nullptr):
name (n), formals (f), body (b),
typeAnnotation(typeAnnotation)
{ kind = K; }
@@ -2388,7 +2388,7 @@ public:
FunctionExpression *asFunctionDefinition() override;
// attributes
- QStringRef name;
+ QStringView name;
bool isArrowFunction = false;
bool isGenerator = false;
FormalParameterList *formals;
@@ -2407,7 +2407,7 @@ class QML_PARSER_EXPORT FunctionDeclaration: public FunctionExpression
public:
QQMLJS_DECLARE_AST_NODE(FunctionDeclaration)
- FunctionDeclaration(const QStringRef &n, FormalParameterList *f, StatementList *b, TypeAnnotation *typeAnnotation = nullptr):
+ FunctionDeclaration(QStringView n, FormalParameterList *f, StatementList *b, TypeAnnotation *typeAnnotation = nullptr):
FunctionExpression(n, f, b, typeAnnotation)
{ kind = K; }
@@ -2504,7 +2504,7 @@ class QML_PARSER_EXPORT ClassExpression : public ExpressionNode
public:
QQMLJS_DECLARE_AST_NODE(ClassExpression)
- ClassExpression(const QStringRef &n, ExpressionNode *heritage, ClassElementList *elements)
+ ClassExpression(QStringView n, ExpressionNode *heritage, ClassElementList *elements)
: name(n), heritage(heritage), elements(elements)
{ kind = K; }
@@ -2519,7 +2519,7 @@ public:
ClassExpression *asClassDefinition() override;
// attributes
- QStringRef name;
+ QStringView name;
ExpressionNode *heritage;
ClassElementList *elements;
SourceLocation classToken;
@@ -2533,7 +2533,7 @@ class QML_PARSER_EXPORT ClassDeclaration: public ClassExpression
public:
QQMLJS_DECLARE_AST_NODE(ClassDeclaration)
- ClassDeclaration(const QStringRef &n, ExpressionNode *heritage, ClassElementList *elements)
+ ClassDeclaration(QStringView n, ExpressionNode *heritage, ClassElementList *elements)
: ClassExpression(n, heritage, elements)
{ kind = K; }
@@ -2604,13 +2604,13 @@ class QML_PARSER_EXPORT ImportSpecifier: public Node
public:
QQMLJS_DECLARE_AST_NODE(ImportSpecifier)
- ImportSpecifier(const QStringRef &importedBinding)
+ ImportSpecifier(QStringView importedBinding)
: importedBinding(importedBinding)
{
kind = K;
}
- ImportSpecifier(const QStringRef &identifier, const QStringRef &importedBinding)
+ ImportSpecifier(QStringView identifier, QStringView importedBinding)
: identifier(identifier), importedBinding(importedBinding)
{
kind = K;
@@ -2626,8 +2626,8 @@ public:
// attributes
SourceLocation identifierToken;
SourceLocation importedBindingToken;
- QStringRef identifier;
- QStringRef importedBinding;
+ QStringView identifier;
+ QStringView importedBinding;
};
class QML_PARSER_EXPORT ImportsList: public Node
@@ -2711,7 +2711,7 @@ class QML_PARSER_EXPORT NameSpaceImport: public Node
public:
QQMLJS_DECLARE_AST_NODE(NameSpaceImport)
- NameSpaceImport(const QStringRef &importedBinding)
+ NameSpaceImport(QStringView importedBinding)
: importedBinding(importedBinding)
{
kind = K;
@@ -2727,7 +2727,7 @@ public:
// attributes
SourceLocation starToken;
SourceLocation importedBindingToken;
- QStringRef importedBinding;
+ QStringView importedBinding;
};
class QML_PARSER_EXPORT ImportClause: public Node
@@ -2735,7 +2735,7 @@ class QML_PARSER_EXPORT ImportClause: public Node
public:
QQMLJS_DECLARE_AST_NODE(ImportClause)
- ImportClause(const QStringRef &importedDefaultBinding)
+ ImportClause(QStringView importedDefaultBinding)
: importedDefaultBinding(importedDefaultBinding)
{
kind = K;
@@ -2753,14 +2753,14 @@ public:
kind = K;
}
- ImportClause(const QStringRef &importedDefaultBinding, NameSpaceImport *nameSpaceImport)
+ ImportClause(QStringView importedDefaultBinding, NameSpaceImport *nameSpaceImport)
: importedDefaultBinding(importedDefaultBinding)
, nameSpaceImport(nameSpaceImport)
{
kind = K;
}
- ImportClause(const QStringRef &importedDefaultBinding, NamedImports *namedImports)
+ ImportClause(QStringView importedDefaultBinding, NamedImports *namedImports)
: importedDefaultBinding(importedDefaultBinding)
, namedImports(namedImports)
{
@@ -2776,7 +2776,7 @@ public:
// attributes
SourceLocation importedDefaultBindingToken;
- QStringRef importedDefaultBinding;
+ QStringView importedDefaultBinding;
NameSpaceImport *nameSpaceImport = nullptr;
NamedImports *namedImports = nullptr;
};
@@ -2786,7 +2786,7 @@ class QML_PARSER_EXPORT FromClause: public Node
public:
QQMLJS_DECLARE_AST_NODE(FromClause)
- FromClause(const QStringRef &moduleSpecifier)
+ FromClause(QStringView moduleSpecifier)
: moduleSpecifier(moduleSpecifier)
{
kind = K;
@@ -2803,7 +2803,7 @@ public:
// attributes
SourceLocation fromToken;
SourceLocation moduleSpecifierToken;
- QStringRef moduleSpecifier;
+ QStringView moduleSpecifier;
};
class QML_PARSER_EXPORT ImportDeclaration: public Statement
@@ -2817,7 +2817,7 @@ public:
kind = K;
}
- ImportDeclaration(const QStringRef &moduleSpecifier)
+ ImportDeclaration(QStringView moduleSpecifier)
: moduleSpecifier(moduleSpecifier)
{
kind = K;
@@ -2834,7 +2834,7 @@ public:
// attributes
SourceLocation importToken;
SourceLocation moduleSpecifierToken;
- QStringRef moduleSpecifier;
+ QStringView moduleSpecifier;
ImportClause *importClause = nullptr;
FromClause *fromClause = nullptr;
};
@@ -2844,13 +2844,13 @@ class QML_PARSER_EXPORT ExportSpecifier: public Node
public:
QQMLJS_DECLARE_AST_NODE(ExportSpecifier)
- ExportSpecifier(const QStringRef &identifier)
+ ExportSpecifier(QStringView identifier)
: identifier(identifier), exportedIdentifier(identifier)
{
kind = K;
}
- ExportSpecifier(const QStringRef &identifier, const QStringRef &exportedIdentifier)
+ ExportSpecifier(QStringView identifier, QStringView exportedIdentifier)
: identifier(identifier), exportedIdentifier(exportedIdentifier)
{
kind = K;
@@ -2866,8 +2866,8 @@ public:
// attributes
SourceLocation identifierToken;
SourceLocation exportedIdentifierToken;
- QStringRef identifier;
- QStringRef exportedIdentifier;
+ QStringView identifier;
+ QStringView exportedIdentifier;
};
class QML_PARSER_EXPORT ExportsList: public Node
@@ -3038,7 +3038,7 @@ class QML_PARSER_EXPORT UiImport: public Node
public:
QQMLJS_DECLARE_AST_NODE(UiImport)
- UiImport(const QStringRef &fileName)
+ UiImport(QStringView fileName)
: fileName(fileName), importUri(nullptr)
{ kind = K; }
@@ -3055,9 +3055,9 @@ public:
{ return semicolonToken; }
// attributes
- QStringRef fileName;
+ QStringView fileName;
UiQualifiedId *importUri;
- QStringRef importId;
+ QStringView importId;
SourceLocation importToken;
SourceLocation fileNameToken;
SourceLocation asToken;
@@ -3120,7 +3120,7 @@ class QML_PARSER_EXPORT UiPragma: public Node
public:
QQMLJS_DECLARE_AST_NODE(UiPragma)
- UiPragma(QStringRef name)
+ UiPragma(QStringView name)
: name(name)
{ kind = K; }
@@ -3133,7 +3133,7 @@ public:
{ return semicolonToken; }
// attributes
- QStringRef name;
+ QStringView name;
SourceLocation pragmaToken;
SourceLocation semicolonToken;
};
@@ -3143,7 +3143,7 @@ class QML_PARSER_EXPORT UiRequired: public Node
public:
QQMLJS_DECLARE_AST_NODE(UiRequired)
- UiRequired(QStringRef name)
+ UiRequired(QStringView name)
:name(name)
{ kind = K; }
@@ -3155,7 +3155,7 @@ public:
SourceLocation lastSourceLocation() const override
{ return semicolonToken; }
- QStringRef name;
+ QStringView name;
SourceLocation requiredToken;
SourceLocation semicolonToken;
};
@@ -3309,11 +3309,11 @@ class QML_PARSER_EXPORT UiParameterList: public Node
public:
QQMLJS_DECLARE_AST_NODE(UiParameterList)
- UiParameterList(UiQualifiedId *t, const QStringRef &n):
+ UiParameterList(UiQualifiedId *t, QStringView n):
type (t), name (n), next (this)
{ kind = K; }
- UiParameterList(UiParameterList *previous, UiQualifiedId *t, const QStringRef &n):
+ UiParameterList(UiParameterList *previous, UiQualifiedId *t, QStringView n):
type (t), name (n)
{
kind = K;
@@ -3341,7 +3341,7 @@ public:
// attributes
UiQualifiedId *type;
- QStringRef name;
+ QStringView name;
UiParameterList *next;
SourceLocation commaToken;
SourceLocation propertyTypeToken;
@@ -3355,12 +3355,12 @@ public:
QQMLJS_DECLARE_AST_NODE(UiPublicMember)
UiPublicMember(UiQualifiedId *memberType,
- const QStringRef &name)
+ QStringView name)
: type(Property), memberType(memberType), name(name), statement(nullptr), binding(nullptr), isDefaultMember(false), isReadonlyMember(false), parameters(nullptr)
{ kind = K; }
UiPublicMember(UiQualifiedId *memberType,
- const QStringRef &name,
+ QStringView name,
Statement *statement)
: type(Property), memberType(memberType), name(name), statement(statement), binding(nullptr), isDefaultMember(false), isReadonlyMember(false), parameters(nullptr)
{ kind = K; }
@@ -3391,9 +3391,9 @@ public:
// attributes
enum { Signal, Property } type;
- QStringRef typeModifier;
+ QStringView typeModifier;
UiQualifiedId *memberType;
- QStringRef name;
+ QStringView name;
Statement *statement; // initialized with a JS expression
UiObjectMember *binding; // initialized with a QML object or array.
bool isDefaultMember;
@@ -3440,7 +3440,7 @@ class QML_PARSER_EXPORT UiInlineComponent: public UiObjectMember
public:
QQMLJS_DECLARE_AST_NODE(UiInlineComponent)
- UiInlineComponent(const QStringRef& inlineComponentName, UiObjectDefinition* inlineComponent)
+ UiInlineComponent(QStringView inlineComponentName, UiObjectDefinition* inlineComponent)
: name(inlineComponentName), component(inlineComponent)
{ kind = K; }
@@ -3453,7 +3453,7 @@ public:
void accept0(BaseVisitor *visitor) override;
// attributes
- QStringRef name;
+ QStringView name;
UiObjectDefinition* component;
SourceLocation componentToken;
};
@@ -3586,11 +3586,11 @@ class QML_PARSER_EXPORT UiEnumMemberList: public Node
{
QQMLJS_DECLARE_AST_NODE(UiEnumMemberList)
public:
- UiEnumMemberList(const QStringRef &member, double v = 0.0)
+ UiEnumMemberList(QStringView member, double v = 0.0)
: next(this), member(member), value(v)
{ kind = K; }
- UiEnumMemberList(UiEnumMemberList *previous, const QStringRef &member)
+ UiEnumMemberList(UiEnumMemberList *previous, QStringView member)
: member(member)
{
kind = K;
@@ -3599,7 +3599,7 @@ public:
value = previous->value + 1;
}
- UiEnumMemberList(UiEnumMemberList *previous, const QStringRef &member, double v)
+ UiEnumMemberList(UiEnumMemberList *previous, QStringView member, double v)
: member(member), value(v)
{
kind = K;
@@ -3627,7 +3627,7 @@ public:
// attributes
UiEnumMemberList *next;
- QStringRef member;
+ QStringView member;
double value;
SourceLocation memberToken;
SourceLocation valueToken;
@@ -3638,7 +3638,7 @@ class QML_PARSER_EXPORT UiEnumDeclaration: public UiObjectMember
public:
QQMLJS_DECLARE_AST_NODE(UiEnumDeclaration)
- UiEnumDeclaration(const QStringRef &name,
+ UiEnumDeclaration(QStringView name,
UiEnumMemberList *members)
: name(name)
, members(members)
@@ -3655,7 +3655,7 @@ public:
// attributes
SourceLocation enumToken;
SourceLocation rbraceToken;
- QStringRef name;
+ QStringView name;
UiEnumMemberList *members;
};
diff --git a/src/qml/parser/qqmljsengine_p.cpp b/src/qml/parser/qqmljsengine_p.cpp
index cb6b0375e6..53ad8820dd 100644
--- a/src/qml/parser/qqmljsengine_p.cpp
+++ b/src/qml/parser/qqmljsengine_p.cpp
@@ -143,14 +143,13 @@ void Engine::setDirectives(Directives *directives)
MemoryPool *Engine::pool()
{ return &_pool; }
-QStringRef Engine::newStringRef(const QString &text)
+QStringView Engine::newStringRef(const QString &text)
{
- const int pos = _extraCode.length();
- _extraCode += text;
- return _extraCode.midRef(pos, text.length());
+ _extraCode.append(text);
+ return QStringView{_extraCode.last()};
}
-QStringRef Engine::newStringRef(const QChar *chars, int size)
+QStringView Engine::newStringRef(const QChar *chars, int size)
{ return newStringRef(QString(chars, size)); }
} // end of namespace QQmlJS
diff --git a/src/qml/parser/qqmljsengine_p.h b/src/qml/parser/qqmljsengine_p.h
index a34922fa1e..b57515982b 100644
--- a/src/qml/parser/qqmljsengine_p.h
+++ b/src/qml/parser/qqmljsengine_p.h
@@ -98,7 +98,7 @@ class QML_PARSER_EXPORT Engine
Directives *_directives;
MemoryPool _pool;
QList<SourceLocation> _comments;
- QString _extraCode;
+ QStringList _extraCode;
QString _code;
public:
@@ -119,10 +119,10 @@ public:
MemoryPool *pool();
- inline QStringRef midRef(int position, int size) { return _code.midRef(position, size); }
+ inline QStringView midRef(int position, int size) { return QStringView{_code}.mid(position, size); }
- QStringRef newStringRef(const QString &s);
- QStringRef newStringRef(const QChar *chars, int size);
+ QStringView newStringRef(const QString &s);
+ QStringView newStringRef(const QChar *chars, int size);
};
double integerFromString(const char *buf, int size, int radix);
diff --git a/src/qml/parser/qqmljslexer.cpp b/src/qml/parser/qqmljslexer.cpp
index cdab17ff63..601596a9e3 100644
--- a/src/qml/parser/qqmljslexer.cpp
+++ b/src/qml/parser/qqmljslexer.cpp
@@ -132,8 +132,8 @@ void Lexer::setCode(const QString &code, int lineno, bool qmlMode)
_tokenText.clear();
_tokenText.reserve(1024);
_errorMessage.clear();
- _tokenSpell = QStringRef();
- _rawString = QStringRef();
+ _tokenSpell = QStringView();
+ _rawString = QStringView();
_codePtr = code.unicode();
_endPtr = _codePtr + code.length();
@@ -256,8 +256,8 @@ int Lexer::lex()
const int previousTokenKind = _tokenKind;
again:
- _tokenSpell = QStringRef();
- _rawString = QStringRef();
+ _tokenSpell = QStringView();
+ _rawString = QStringView();
_tokenKind = scanToken();
_tokenLength = _codePtr - _tokenStartPtr - 1;
diff --git a/src/qml/parser/qqmljslexer_p.h b/src/qml/parser/qqmljslexer_p.h
index e2ee4ae351..7b4c219506 100644
--- a/src/qml/parser/qqmljslexer_p.h
+++ b/src/qml/parser/qqmljslexer_p.h
@@ -165,8 +165,8 @@ public:
int tokenStartLine() const { return _tokenLine; }
int tokenStartColumn() const { return _tokenColumn; }
- inline QStringRef tokenSpell() const { return _tokenSpell; }
- inline QStringRef rawString() const { return _rawString; }
+ inline QStringView tokenSpell() const { return _tokenSpell; }
+ inline QStringView rawString() const { return _rawString; }
double tokenValue() const { return _tokenValue; }
QString tokenText() const;
@@ -219,8 +219,8 @@ private:
QString _code;
QString _tokenText;
QString _errorMessage;
- QStringRef _tokenSpell;
- QStringRef _rawString;
+ QStringView _tokenSpell;
+ QStringView _rawString;
const QChar *_codePtr;
const QChar *_endPtr;
diff --git a/src/qml/qml/ftw/qhashedstring_p.h b/src/qml/qml/ftw/qhashedstring_p.h
index 08f019b4bd..c5353acdb1 100644
--- a/src/qml/qml/ftw/qhashedstring_p.h
+++ b/src/qml/qml/ftw/qhashedstring_p.h
@@ -100,7 +100,7 @@ class Q_QML_PRIVATE_EXPORT QHashedStringRef
public:
inline QHashedStringRef();
inline QHashedStringRef(const QString &);
- inline QHashedStringRef(const QStringRef &);
+ inline QHashedStringRef(QStringView);
inline QHashedStringRef(const QChar *, int);
inline QHashedStringRef(const QChar *, int, quint32);
inline QHashedStringRef(const QHashedString &);
@@ -242,7 +242,7 @@ QHashedStringRef::QHashedStringRef(const QString &str)
{
}
-QHashedStringRef::QHashedStringRef(const QStringRef &str)
+QHashedStringRef::QHashedStringRef(QStringView str)
: m_data(str.constData()), m_length(str.length()), m_hash(0)
{
}
diff --git a/src/qml/qml/ftw/qstringhash_p.h b/src/qml/qml/ftw/qstringhash_p.h
index b785525ea4..7a2184d63f 100644
--- a/src/qml/qml/ftw/qstringhash_p.h
+++ b/src/qml/qml/ftw/qstringhash_p.h
@@ -253,7 +253,7 @@ template<typename T>
struct HashedForm {};
template<> struct HashedForm<QString> { typedef QHashedString Type; };
-template<> struct HashedForm<QStringRef> { typedef QHashedStringRef Type; };
+template<> struct HashedForm<QStringView> { typedef QHashedStringRef Type; };
template<> struct HashedForm<QHashedString> { typedef const QHashedString &Type; };
template<> struct HashedForm<QV4::String *> { typedef const QV4::String *Type; };
template<> struct HashedForm<const QV4::String *> { typedef const QV4::String *Type; };
@@ -265,7 +265,7 @@ class QStringHashBase
{
public:
static HashedForm<QString>::Type hashedString(const QString &s) { return QHashedString(s);}
- static HashedForm<QStringRef>::Type hashedString(const QStringRef &s) { return QHashedStringRef(s.constData(), s.size());}
+ static HashedForm<QStringView>::Type hashedString(QStringView s) { return QHashedStringRef(s.constData(), s.size());}
static HashedForm<QHashedString>::Type hashedString(const QHashedString &s) { return s; }
static HashedForm<QV4::String *>::Type hashedString(QV4::String *s) { return s; }
static HashedForm<const QV4::String *>::Type hashedString(const QV4::String *s) { return s; }
diff --git a/src/qml/qml/qqmlerror.cpp b/src/qml/qml/qqmlerror.cpp
index c71c33a059..706cc8601d 100644
--- a/src/qml/qml/qqmlerror.cpp
+++ b/src/qml/qml/qqmlerror.cpp
@@ -318,10 +318,10 @@ QDebug operator<<(QDebug debug, const QQmlError &error)
QByteArray data = f.readAll();
QTextStream stream(data, QIODevice::ReadOnly);
const QString code = stream.readAll();
- const auto lines = code.splitRef(QLatin1Char('\n'));
+ const auto lines = QStringView{code}.split(QLatin1Char('\n'));
if (lines.count() >= error.line()) {
- const QStringRef &line = lines.at(error.line() - 1);
+ const QStringView &line = lines.at(error.line() - 1);
debug << "\n " << line.toLocal8Bit().constData();
if(error.column() > 0) {
diff --git a/src/qml/qml/qqmlfile.cpp b/src/qml/qml/qqmlfile.cpp
index 465a342129..4db8981975 100644
--- a/src/qml/qml/qqmlfile.cpp
+++ b/src/qml/qml/qqmlfile.cpp
@@ -616,13 +616,13 @@ QString QQmlFile::urlToLocalFileOrQrc(const QString& url)
{
if (url.startsWith(QLatin1String("qrc://"), Qt::CaseInsensitive)) {
if (url.length() > 6)
- return QLatin1Char(':') + url.midRef(6);
+ return QLatin1Char(':') + QStringView{url}.mid(6);
return QString();
}
if (url.startsWith(QLatin1String("qrc:"), Qt::CaseInsensitive)) {
if (url.length() > 4)
- return QLatin1Char(':') + url.midRef(4);
+ return QLatin1Char(':') + QStringView{url}.mid(4);
return QString();
}
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index a5429afd12..ad7cda2145 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -92,7 +92,7 @@ QString resolveLocalUrl(const QString &url, const QString &relative)
} else if (relative.at(0) == Slash || !url.contains(Slash)) {
return relative;
} else {
- const QStringRef baseRef = url.leftRef(url.lastIndexOf(Slash) + 1);
+ const QStringView baseRef = QStringView{url}.left(url.lastIndexOf(Slash) + 1);
if (relative == QLatin1String("."))
return baseRef.toString();
@@ -406,7 +406,7 @@ bool excludeBaseUrl(const QString &importUrl, const QString &fileName, const QSt
if (baseUrl.startsWith(importUrl))
{
- if (fileName == baseUrl.midRef(importUrl.size()))
+ if (fileName == QStringView{baseUrl}.mid(importUrl.size()))
return false;
}
@@ -1000,17 +1000,17 @@ bool QQmlImportNamespace::resolveType(QQmlTypeLoader *typeLoader, const QHashedS
QString u1 = import->url;
QString u2 = import2->url;
if (base) {
- QStringRef b(base);
+ QStringView b(*base);
int dot = b.lastIndexOf(Dot);
if (dot >= 0) {
b = b.left(dot+1);
- QStringRef l = b.left(dot);
+ QStringView l = b.left(dot);
if (u1.startsWith(b))
- u1 = u1.mid(b.count());
+ u1 = u1.mid(b.size());
else if (u1 == l)
u1 = QQmlImportDatabase::tr("local directory");
if (u2.startsWith(b))
- u2 = u2.mid(b.count());
+ u2 = u2.mid(b.size());
else if (u2 == l)
u2 = QQmlImportDatabase::tr("local directory");
}
@@ -1400,7 +1400,7 @@ QQmlImports::LocalQmldirResult QQmlImportsPrivate::locateLocalQmldir(
QString absoluteFilePath = typeLoader.absoluteFilePath(qmldirPath);
if (!absoluteFilePath.isEmpty()) {
QString url;
- const QStringRef absolutePath = absoluteFilePath.leftRef(absoluteFilePath.lastIndexOf(Slash) + 1);
+ const QStringView absolutePath = QStringView{absoluteFilePath}.left(absoluteFilePath.lastIndexOf(Slash) + 1);
if (absolutePath.at(0) == Colon)
url = QLatin1String("qrc") + absolutePath;
else
diff --git a/src/qml/qml/qqmlinfo.h b/src/qml/qml/qqmlinfo.h
index faa112d4af..a3ceb405b8 100644
--- a/src/qml/qml/qqmlinfo.h
+++ b/src/qml/qml/qqmlinfo.h
@@ -91,7 +91,7 @@ public:
inline QQmlInfo &operator<<(double t) { QDebug::operator<<(t); return *this; }
inline QQmlInfo &operator<<(const char* t) { QDebug::operator<<(t); return *this; }
inline QQmlInfo &operator<<(const QString & t) { QDebug::operator<<(t.toLocal8Bit().constData()); return *this; }
- inline QQmlInfo &operator<<(const QStringRef & t) { return operator<<(t.toString()); }
+ inline QQmlInfo &operator<<(QStringView t) { return operator<<(t.toString()); }
inline QQmlInfo &operator<<(const QLatin1String &t) { QDebug::operator<<(t.latin1()); return *this; }
inline QQmlInfo &operator<<(const QByteArray & t) { QDebug::operator<<(t); return *this; }
inline QQmlInfo &operator<<(const void * t) { QDebug::operator<<(t); return *this; }
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index 77a1d0d74a..561c336b66 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -1481,7 +1481,7 @@ QString QQmlMetaType::prettyTypeName(const QObject *object)
marker = typeName.indexOf(QLatin1String("_QML_"));
if (marker != -1) {
- typeName = typeName.leftRef(marker) + QLatin1Char('*');
+ typeName = QStringView{typeName}.left(marker) + QLatin1Char('*');
type = QQmlMetaType::qmlType(QMetaType::type(typeName.toLatin1()));
if (type.isValid()) {
QString qmlTypeName = type.qmlTypeName();
diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp
index 9595675ba6..864f97a417 100644
--- a/src/qml/qml/qqmlproperty.cpp
+++ b/src/qml/qml/qqmlproperty.cpp
@@ -262,16 +262,16 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name)
QQmlRefPointer<QQmlTypeNameCache> typeNameCache = context ? context->imports() : nullptr;
QObject *currentObject = obj;
- QVector<QStringRef> path;
- QStringRef terminal(&name);
+ QList<QStringView> path;
+ QStringView terminal(name);
if (name.contains(QLatin1Char('.'))) {
- path = name.splitRef(QLatin1Char('.'));
+ path = QStringView{name}.split(QLatin1Char('.'));
if (path.isEmpty()) return;
// Everything up to the last property must be an "object type" property
for (int ii = 0; ii < path.count() - 1; ++ii) {
- const QStringRef &pathName = path.at(ii);
+ const QStringView &pathName = path.at(ii);
// Types must begin with an uppercase letter (see checkRegistration()
// in qqmlmetatype.cpp for the enforcement of this).
@@ -355,7 +355,7 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name)
terminal = path.last();
}
- if (terminal.count() >= 3 && terminal.at(0) == u'o' && terminal.at(1) == u'n'
+ if (terminal.size() >= 3 && terminal.at(0) == u'o' && terminal.at(1) == u'n'
&& (terminal.at(2).isUpper() || terminal.at(2) == u'_')) {
QString signalName = terminal.mid(2).toString();
@@ -384,7 +384,7 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name)
// Try property
if (signalName.endsWith(QLatin1String("Changed"))) {
- const QStringRef propName = signalName.midRef(0, signalName.length() - 7);
+ const QStringView propName = QStringView{signalName}.mid(0, signalName.length() - 7);
QQmlPropertyData *d = ddata->propertyCache->property(propName, currentObject, context);
while (d && d->isFunction())
d = ddata->propertyCache->overrideData(d);
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
index 5fef36e0df..5f91b5b94a 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -551,7 +551,7 @@ void QQmlPropertyCache::append(const QMetaObject *metaObject,
setNamedProperty(methodName, ii, data, (old != nullptr));
if (data->isSignal()) {
- QHashedString on(QLatin1String("on") % methodName.at(0).toUpper() % methodName.midRef(1));
+ QHashedString on(QLatin1String("on") % methodName.at(0).toUpper() % QStringView{methodName}.mid(1));
setNamedProperty(on, ii, sigdata, (old != nullptr));
++signalHandlerIndex;
}
@@ -991,7 +991,7 @@ static inline const char *qQmlPropertyCacheToString(QLatin1String string)
return string.data();
}
-static inline QByteArray qQmlPropertyCacheToString(const QStringRef &string)
+static inline QByteArray qQmlPropertyCacheToString(QStringView string)
{
return string.toUtf8();
}
@@ -1043,10 +1043,10 @@ QQmlPropertyCache::property(QJSEngine *engine, QObject *obj, const QV4::String *
}
QQmlPropertyData *
-QQmlPropertyCache::property(QJSEngine *engine, QObject *obj, const QStringRef &name,
+QQmlPropertyCache::property(QJSEngine *engine, QObject *obj, QStringView name,
const QQmlRefPointer<QQmlContextData> &context, QQmlPropertyData *local)
{
- return qQmlPropertyCacheProperty<const QStringRef &>(engine, obj, name, context, local);
+ return qQmlPropertyCacheProperty<const QStringView &>(engine, obj, name, context, local);
}
QQmlPropertyData *
diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h
index a6517cc3ff..460e6d9a85 100644
--- a/src/qml/qml/qqmlpropertycache_p.h
+++ b/src/qml/qml/qqmlpropertycache_p.h
@@ -185,7 +185,7 @@ public:
inline QQmlPropertyData *overrideData(QQmlPropertyData *) const;
inline bool isAllowedInRevision(QQmlPropertyData *) const;
- static QQmlPropertyData *property(QJSEngine *, QObject *, const QStringRef &,
+ static QQmlPropertyData *property(QJSEngine *, QObject *, QStringView,
const QQmlRefPointer<QQmlContextData> &, QQmlPropertyData *);
static QQmlPropertyData *property(QJSEngine *, QObject *, const QLatin1String &,
const QQmlRefPointer<QQmlContextData> &, QQmlPropertyData *);
@@ -196,7 +196,7 @@ public:
const QQmlRefPointer<QQmlContextData> &context,
QQmlPropertyData *local)
{
- return property(engine, obj, QStringRef(&name), context, local);
+ return property(engine, obj, QStringView(name), context, local);
}
//see QMetaObjectPrivate::originalClone
diff --git a/src/qml/qml/qqmlpropertycachecreator.cpp b/src/qml/qml/qqmlpropertycachecreator.cpp
index f132fb2d78..777a698231 100644
--- a/src/qml/qml/qqmlpropertycachecreator.cpp
+++ b/src/qml/qml/qqmlpropertycachecreator.cpp
@@ -82,7 +82,7 @@ QByteArray QQmlPropertyCacheCreatorBase::createClassNameTypeByUrl(const QUrl &ur
if (lastSlash <= -1)
return QByteArray();
// ### this might not be correct for .ui.qml files
- const QStringRef nameBase = path.midRef(lastSlash + 1, path.length() - lastSlash - 5);
+ const QStringView nameBase = QStringView{path}.mid(lastSlash + 1, path.length() - lastSlash - 5);
// Not a reusable type if it doesn't start with a upper case letter.
if (nameBase.isEmpty() || !nameBase.at(0).isUpper())
return QByteArray();
diff --git a/src/qml/qml/qqmlstringconverters.cpp b/src/qml/qml/qqmlstringconverters.cpp
index e53f90b45b..d1c7d8cdf3 100644
--- a/src/qml/qml/qqmlstringconverters.cpp
+++ b/src/qml/qml/qqmlstringconverters.cpp
@@ -143,8 +143,8 @@ QPointF QQmlStringConverters::pointFFromString(const QString &s, bool *ok)
bool xGood, yGood;
int index = s.indexOf(QLatin1Char(','));
- qreal xCoord = s.leftRef(index).toDouble(&xGood);
- qreal yCoord = s.midRef(index+1).toDouble(&yGood);
+ qreal xCoord = QStringView{s}.left(index).toDouble(&xGood);
+ qreal yCoord = QStringView{s}.mid(index+1).toDouble(&yGood);
if (!xGood || !yGood) {
if (ok)
*ok = false;
@@ -167,8 +167,8 @@ QSizeF QQmlStringConverters::sizeFFromString(const QString &s, bool *ok)
bool wGood, hGood;
int index = s.indexOf(QLatin1Char('x'));
- qreal width = s.leftRef(index).toDouble(&wGood);
- qreal height = s.midRef(index+1).toDouble(&hGood);
+ qreal width = QStringView{s}.left(index).toDouble(&wGood);
+ qreal height = QStringView{s}.mid(index+1).toDouble(&hGood);
if (!wGood || !hGood) {
if (ok)
*ok = false;
@@ -191,12 +191,12 @@ QRectF QQmlStringConverters::rectFFromString(const QString &s, bool *ok)
bool xGood, yGood, wGood, hGood;
int index = s.indexOf(QLatin1Char(','));
- qreal x = s.leftRef(index).toDouble(&xGood);
+ qreal x = QStringView{s}.left(index).toDouble(&xGood);
int index2 = s.indexOf(QLatin1Char(','), index+1);
- qreal y = s.midRef(index+1, index2-index-1).toDouble(&yGood);
+ qreal y = QStringView{s}.mid(index+1, index2-index-1).toDouble(&yGood);
index = s.indexOf(QLatin1Char('x'), index2+1);
- qreal width = s.midRef(index2+1, index-index2-1).toDouble(&wGood);
- qreal height = s.midRef(index+1).toDouble(&hGood);
+ qreal width = QStringView{s}.mid(index2+1, index-index2-1).toDouble(&wGood);
+ qreal height = QStringView{s}.mid(index+1).toDouble(&hGood);
if (!xGood || !yGood || !wGood || !hGood) {
if (ok)
*ok = false;
diff --git a/src/qml/qml/qqmltype.cpp b/src/qml/qml/qqmltype.cpp
index 5ae87c429d..1d343b91cc 100644
--- a/src/qml/qml/qqmltype.cpp
+++ b/src/qml/qml/qqmltype.cpp
@@ -846,7 +846,7 @@ int QQmlType::scopedEnumValue(QQmlEnginePrivate *engine, const QByteArray &scope
return -1;
}
-int QQmlType::scopedEnumValue(QQmlEnginePrivate *engine, const QStringRef &scopedEnumName, const QStringRef &name, bool *ok) const
+int QQmlType::scopedEnumValue(QQmlEnginePrivate *engine, QStringView scopedEnumName, QStringView name, bool *ok) const
{
Q_ASSERT(ok);
if (d) {
diff --git a/src/qml/qml/qqmltype_p.h b/src/qml/qml/qqmltype_p.h
index eb3a773181..929a5d0c81 100644
--- a/src/qml/qml/qqmltype_p.h
+++ b/src/qml/qml/qqmltype_p.h
@@ -169,7 +169,7 @@ public:
int scopedEnumValue(QQmlEnginePrivate *engine, int index, const QV4::String *, bool *ok) const;
int scopedEnumValue(QQmlEnginePrivate *engine, int index, const QString &, bool *ok) const;
int scopedEnumValue(QQmlEnginePrivate *engine, const QByteArray &, const QByteArray &, bool *ok) const;
- int scopedEnumValue(QQmlEnginePrivate *engine, const QStringRef &, const QStringRef &, bool *ok) const;
+ int scopedEnumValue(QQmlEnginePrivate *engine, QStringView, QStringView, bool *ok) const;
int inlineComponentObjectId() const;
void setInlineComponentObjectId(int id) const; // TODO: const setters are BAD
diff --git a/src/qml/qml/qqmltypecompiler.cpp b/src/qml/qml/qqmltypecompiler.cpp
index 6a4966ffba..a9f5cdbf8d 100644
--- a/src/qml/qml/qqmltypecompiler.cpp
+++ b/src/qml/qml/qqmltypecompiler.cpp
@@ -249,7 +249,7 @@ QQmlJS::MemoryPool *QQmlTypeCompiler::memoryPool()
return document->jsParserEngine.pool();
}
-QStringRef QQmlTypeCompiler::newStringRef(const QString &string)
+QStringView QQmlTypeCompiler::newStringRef(const QString &string)
{
return document->jsParserEngine.newStringRef(string);
}
@@ -468,7 +468,7 @@ bool SignalHandlerConverter::convertSignalHandlerExpressionsToFunctionDeclaratio
QQmlJS::AST::FormalParameterList *paramList = nullptr;
for (const QString &param : qAsConst(parameters)) {
- QStringRef paramNameRef = compiler->newStringRef(param);
+ QStringView paramNameRef = compiler->newStringRef(param);
QQmlJS::AST::PatternElement *b = new (pool) QQmlJS::AST::PatternElement(paramNameRef, nullptr);
paramList = new (pool) QQmlJS::AST::FormalParameterList(paramList, b);
@@ -551,7 +551,7 @@ bool QQmlEnumTypeResolver::resolveEnumBindings()
return true;
}
-bool QQmlEnumTypeResolver::assignEnumToBinding(QmlIR::Binding *binding, const QStringRef &, int enumValue, bool)
+bool QQmlEnumTypeResolver::assignEnumToBinding(QmlIR::Binding *binding, QStringView, int enumValue, bool)
{
binding->type = QV4::CompiledData::Binding::Type_Number;
binding->value.constantValueIndex = compiler->registerConstant(QV4::Encode((double)enumValue));
@@ -592,9 +592,9 @@ bool QQmlEnumTypeResolver::tryQualifiedEnumAssignment(const QmlIR::Object *obj,
QHashedStringRef typeName(string.constData(), dot);
const bool isQtObject = (typeName == QLatin1String("Qt"));
- const QStringRef scopedEnumName = (dot2 != -1 ? string.midRef(dot + 1, dot2 - dot - 1) : QStringRef());
+ const QStringView scopedEnumName = (dot2 != -1 ? QStringView{string}.mid(dot + 1, dot2 - dot - 1) : QStringView());
// ### consider supporting scoped enums in Qt namespace
- const QStringRef enumValue = string.midRef(!isQtObject && dot2 != -1 ? dot2 + 1 : dot + 1);
+ const QStringView enumValue = QStringView{string}.mid(!isQtObject && dot2 != -1 ? dot2 + 1 : dot + 1);
if (isIntProp) { // ### C++11 allows enums to be other integral types. Should we support other integral types here?
// Allow enum assignment to ints.
@@ -652,7 +652,7 @@ bool QQmlEnumTypeResolver::tryQualifiedEnumAssignment(const QmlIR::Object *obj,
return assignEnumToBinding(binding, enumValue, value, isQtObject);
}
-int QQmlEnumTypeResolver::evaluateEnum(const QString &scope, const QStringRef &enumName, const QStringRef &enumValue, bool *ok) const
+int QQmlEnumTypeResolver::evaluateEnum(const QString &scope, QStringView enumName, QStringView enumValue, bool *ok) const
{
Q_ASSERT_X(ok, "QQmlEnumTypeResolver::evaluateEnum", "ok must not be a null pointer");
*ok = false;
@@ -1104,15 +1104,15 @@ QQmlComponentAndAliasResolver::resolveAliasesInObject(int objectIndex,
const QString aliasPropertyValue = stringAt(alias->propertyNameIndex);
- QStringRef property;
- QStringRef subProperty;
+ QStringView property;
+ QStringView subProperty;
const int propertySeparator = aliasPropertyValue.indexOf(QLatin1Char('.'));
if (propertySeparator != -1) {
- property = aliasPropertyValue.leftRef(propertySeparator);
- subProperty = aliasPropertyValue.midRef(propertySeparator + 1);
+ property = QStringView{aliasPropertyValue}.left(propertySeparator);
+ subProperty = QStringView{aliasPropertyValue}.mid(propertySeparator + 1);
} else
- property = QStringRef(&aliasPropertyValue, 0, aliasPropertyValue.length());
+ property = QStringView(aliasPropertyValue);
QQmlPropertyIndex propIdx;
diff --git a/src/qml/qml/qqmltypecompiler_p.h b/src/qml/qml/qqmltypecompiler_p.h
index 883fbf0d68..66562251f9 100644
--- a/src/qml/qml/qqmltypecompiler_p.h
+++ b/src/qml/qml/qqmltypecompiler_p.h
@@ -118,7 +118,7 @@ public:
void setComponentRoots(const QVector<quint32> &roots) { m_componentRoots = roots; }
const QVector<quint32> &componentRoots() const { return m_componentRoots; }
QQmlJS::MemoryPool *memoryPool();
- QStringRef newStringRef(const QString &string);
+ QStringView newStringRef(const QString &string);
const QV4::Compiler::StringTableGenerator *stringPool() const;
const QHash<int, QQmlCustomParser*> &customParserCache() const { return customParsers; }
@@ -207,15 +207,15 @@ public:
bool resolveEnumBindings();
private:
- bool assignEnumToBinding(QmlIR::Binding *binding, const QStringRef &enumName, int enumValue, bool isQtObject);
+ bool assignEnumToBinding(QmlIR::Binding *binding, QStringView enumName, int enumValue, bool isQtObject);
bool assignEnumToBinding(QmlIR::Binding *binding, const QString &enumName, int enumValue, bool isQtObject)
{
- return assignEnumToBinding(binding, QStringRef(&enumName), enumValue, isQtObject);
+ return assignEnumToBinding(binding, QStringView(enumName), enumValue, isQtObject);
}
bool tryQualifiedEnumAssignment(const QmlIR::Object *obj, const QQmlPropertyCache *propertyCache,
const QQmlPropertyData *prop,
QmlIR::Binding *binding);
- int evaluateEnum(const QString &scope, const QStringRef &enumName, const QStringRef &enumValue, bool *ok) const;
+ int evaluateEnum(const QString &scope, QStringView enumName, QStringView enumValue, bool *ok) const;
const QVector<QmlIR::Object*> &qmlObjects;
diff --git a/src/qml/qml/qqmltypedata.cpp b/src/qml/qml/qqmltypedata.cpp
index 32f5bca8d9..d41685b047 100644
--- a/src/qml/qml/qqmltypedata.cpp
+++ b/src/qml/qml/qqmltypedata.cpp
@@ -358,7 +358,7 @@ void QQmlTypeData::done()
error.setUrl(url());
error.setLine(qmlConvertSourceCoordinate<quint32, int>(type.location.line));
error.setColumn(qmlConvertSourceCoordinate<quint32, int>(type.location.column));
- error.setDescription(QQmlTypeLoader::tr("Type %1 has no inline component type called %2").arg(typeName.leftRef(lastDot), type.type.pendingResolutionName()));
+ error.setDescription(QQmlTypeLoader::tr("Type %1 has no inline component type called %2").arg(QStringView{typeName}.left(lastDot), type.type.pendingResolutionName()));
errors.prepend(error);
setError(errors);
return;
@@ -505,7 +505,7 @@ void QQmlTypeData::done()
// associate inline components to root component
{
- auto typeName = finalUrlString().splitRef(u'/').last().split(u'.').first().toString();
+ auto typeName = QStringView{finalUrlString()}.split(u'/').last().split(u'.').first().toString();
// typeName can be empty if a QQmlComponent was constructed with an empty QUrl parameter
if (!typeName.isEmpty() && typeName.at(0).isUpper() && !m_inlineComponentData.isEmpty()) {
QHashedStringRef const hashedStringRef { typeName };
@@ -529,7 +529,7 @@ void QQmlTypeData::done()
for (int scriptIndex = 0; scriptIndex < m_scripts.count(); ++scriptIndex) {
const QQmlTypeData::ScriptReference &script = m_scripts.at(scriptIndex);
- QStringRef qualifier(&script.qualifier);
+ QStringView qualifier(script.qualifier);
QString enclosingNamespace;
const int lastDotIndex = qualifier.lastIndexOf(QLatin1Char('.'));
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 41b8f626f7..9b06bd77ca 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -728,7 +728,7 @@ ReturnedValue Text::method_isElementContentWhitespace(const FunctionObject *b, c
if (!r)
RETURN_UNDEFINED();
- return Encode(QStringRef(&r->d()->d->data).trimmed().isEmpty());
+ return Encode(QStringView(r->d()->d->data).trimmed().isEmpty());
}
ReturnedValue Text::method_wholeText(const FunctionObject *b, const Value *thisObject, const Value *, int)
diff --git a/src/qml/qmldirparser/qqmldirparser.cpp b/src/qml/qmldirparser/qqmldirparser.cpp
index a8a450d2ca..e4d916a10f 100644
--- a/src/qml/qmldirparser/qqmldirparser.cpp
+++ b/src/qml/qmldirparser/qqmldirparser.cpp
@@ -43,7 +43,7 @@
QT_BEGIN_NAMESPACE
-static int parseInt(const QStringRef &str, bool *ok)
+static int parseInt(QStringView str, bool *ok)
{
int pos = 0;
int number = 0;
@@ -65,9 +65,9 @@ static QTypeRevision parseVersion(const QString &str)
const int dotIndex = str.indexOf(QLatin1Char('.'));
if (dotIndex != -1 && str.indexOf(QLatin1Char('.'), dotIndex + 1) == -1) {
bool ok = false;
- const int major = parseInt(QStringRef(&str, 0, dotIndex), &ok);
+ const int major = parseInt(QStringView(str).left(dotIndex), &ok);
if (!ok) return QTypeRevision();
- const int minor = parseInt(QStringRef(&str, dotIndex + 1, str.length() - dotIndex - 1), &ok);
+ const int minor = parseInt(QStringView(str).mid(dotIndex + 1, str.length() - dotIndex - 1), &ok);
return ok ? QTypeRevision::fromVersion(major, minor) : QTypeRevision();
}
return QTypeRevision();
diff --git a/src/qml/qmldirparser/qqmlimportresolver.cpp b/src/qml/qmldirparser/qqmlimportresolver.cpp
index d427706140..25b366556d 100644
--- a/src/qml/qmldirparser/qqmlimportresolver.cpp
+++ b/src/qml/qmldirparser/qqmlimportresolver.cpp
@@ -54,13 +54,13 @@ enum ImportVersion { FullyVersioned, PartiallyVersioned, Unversioned };
- base/QtQml.2/Models
- base/QtQml/Models
*/
-QStringList qQmlResolveImportPaths(const QString &uri, const QStringList &basePaths,
+QStringList qQmlResolveImportPaths(QStringView uri, const QStringList &basePaths,
QTypeRevision version)
{
static const QLatin1Char Slash('/');
static const QLatin1Char Backslash('\\');
- const QVector<QStringRef> parts = uri.splitRef(QLatin1Char('.'), Qt::SkipEmptyParts);
+ const QVector<QStringView> parts = uri.split(u'.', Qt::SkipEmptyParts);
QStringList importPaths;
// fully & partially versioned parts + 1 unversioned for each base path
@@ -81,7 +81,7 @@ QStringList qQmlResolveImportPaths(const QString &uri, const QStringList &basePa
return QString();
};
- auto joinStringRefs = [](const QVector<QStringRef> &refs, const QChar &sep) {
+ auto joinStringRefs = [](const QVector<QStringView> &refs, const QChar &sep) {
QString str;
for (auto it = refs.cbegin(); it != refs.cend(); ++it) {
if (it != refs.cbegin())
diff --git a/src/qml/qmldirparser/qqmlimportresolver_p.h b/src/qml/qmldirparser/qqmlimportresolver_p.h
index bfc0592bf8..c2f49ee4ec 100644
--- a/src/qml/qmldirparser/qqmlimportresolver_p.h
+++ b/src/qml/qmldirparser/qqmlimportresolver_p.h
@@ -57,7 +57,7 @@
QT_BEGIN_NAMESPACE
-QStringList qQmlResolveImportPaths(const QString &uri, const QStringList &basePaths,
+QStringList qQmlResolveImportPaths(QStringView uri, const QStringList &basePaths,
QTypeRevision version);
QT_END_NAMESPACE
diff --git a/src/qmlmodels/qqmldelegatemodel.cpp b/src/qmlmodels/qqmldelegatemodel.cpp
index 287f425ae5..ecbc1465fa 100644
--- a/src/qmlmodels/qqmldelegatemodel.cpp
+++ b/src/qmlmodels/qqmldelegatemodel.cpp
@@ -1365,7 +1365,7 @@ QVariant QQmlDelegateModelPrivate::variantValue(QQmlListCompositor::Group group,
return QVariant();
const int from = dot + 1;
dot = name.indexOf(QLatin1Char('.'), from);
- value = obj->property(name.midRef(from, dot - from).toUtf8());
+ value = obj->property(QStringView{name}.mid(from, dot - from).toUtf8());
}
return value;
}
diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp
index e7c5f61fb4..70b1cf401d 100644
--- a/src/qmltest/quicktest.cpp
+++ b/src/qmltest/quicktest.cpp
@@ -576,7 +576,7 @@ int quick_test_main_with_setup(int argc, char **argv, const char *name, const ch
QTestRootObject::instance()->init();
QString path = fi.absoluteFilePath();
if (path.startsWith(QLatin1String(":/")))
- view.setSource(QUrl(QLatin1String("qrc:") + path.midRef(1)));
+ view.setSource(QUrl(QLatin1String("qrc:") + QStringView{path}.mid(1)));
else
view.setSource(QUrl::fromLocalFile(path));
diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp
index 9ee0dbba04..f182f94357 100644
--- a/src/quick/items/context2d/qquickcanvasitem.cpp
+++ b/src/quick/items/context2d/qquickcanvasitem.cpp
@@ -1133,7 +1133,7 @@ static const char* mimeToType(const QString &mime)
const QLatin1String imagePrefix("image/");
if (!mime.startsWith(imagePrefix))
return nullptr;
- const QStringRef mimeExt = mime.midRef(imagePrefix.size());
+ const QStringView mimeExt = QStringView{mime}.mid(imagePrefix.size());
if (mimeExt == QLatin1String("png"))
return "png";
else if (mimeExt == QLatin1String("bmp"))
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index f7cbf11927..4b231befd9 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -205,7 +205,7 @@ Q_QUICK_PRIVATE_EXPORT QColor qt_color_from_string(const QV4::Value &name)
return QColor();
}
-static int qParseFontSizeFromToken(const QStringRef &fontSizeToken, bool &ok)
+static int qParseFontSizeFromToken(QStringView fontSizeToken, bool &ok)
{
ok = false;
float size = fontSizeToken.trimmed().toFloat(&ok);
@@ -221,11 +221,11 @@ static int qParseFontSizeFromToken(const QStringRef &fontSizeToken, bool &ok)
\c true if successful. If the font size is invalid, \c false is returned
and a warning is printed.
*/
-static bool qSetFontSizeFromToken(QFont &font, const QStringRef &fontSizeToken)
+static bool qSetFontSizeFromToken(QFont &font, QStringView fontSizeToken)
{
- const QStringRef trimmedToken = fontSizeToken.trimmed();
- const QStringRef unitStr = trimmedToken.right(2);
- const QStringRef value = trimmedToken.left(trimmedToken.size() - 2);
+ const QStringView trimmedToken = fontSizeToken.trimmed();
+ const QStringView unitStr = trimmedToken.right(2);
+ const QStringView value = trimmedToken.left(trimmedToken.size() - 2);
bool ok = false;
int size = 0;
if (unitStr == QLatin1String("px")) {
@@ -251,7 +251,7 @@ static bool qSetFontSizeFromToken(QFont &font, const QStringRef &fontSizeToken)
each family is separated by spaces. Families with spaces in their name
must be quoted.
*/
-static QStringList qExtractFontFamiliesFromString(const QStringRef &fontFamiliesString)
+static QStringList qExtractFontFamiliesFromString(QStringView fontFamiliesString)
{
QStringList extractedFamilies;
int quoteIndex = -1;
@@ -395,16 +395,16 @@ static QFont qt_font_from_string(const QString& fontString, const QFont &current
fontSizeEnd += 3;
QFont newFont;
- if (!qSetFontSizeFromToken(newFont, fontString.midRef(fontSizeStart, fontSizeEnd - fontSizeStart)))
+ if (!qSetFontSizeFromToken(newFont, QStringView{fontString}.mid(fontSizeStart, fontSizeEnd - fontSizeStart)))
return currentFont;
// We don't want to parse the size twice, so remove it now.
QString remainingFontString = fontString;
remainingFontString.remove(fontSizeStart, fontSizeEnd - fontSizeStart);
- QStringRef remainingFontStringRef(&remainingFontString);
+ QStringView remainingFontStringRef(remainingFontString);
// Next, we have to take any font families out, as QString::split() will ruin quoted family names.
- const QStringRef fontFamiliesString = remainingFontStringRef.mid(fontSizeStart);
+ const QStringView fontFamiliesString = remainingFontStringRef.mid(fontSizeStart);
remainingFontStringRef.truncate(fontSizeStart);
QStringList fontFamilies = qExtractFontFamiliesFromString(fontFamiliesString);
if (fontFamilies.isEmpty()) {
@@ -414,7 +414,7 @@ static QFont qt_font_from_string(const QString& fontString, const QFont &current
return currentFont;
// Now that we've removed the messy parts, we can split the font string on spaces.
- const QStringRef trimmedTokensStr = remainingFontStringRef.trimmed();
+ const QStringView trimmedTokensStr = remainingFontStringRef.trimmed();
if (trimmedTokensStr.isEmpty()) {
// No optional properties.
return newFont;
@@ -423,7 +423,7 @@ static QFont qt_font_from_string(const QString& fontString, const QFont &current
int usedTokens = NoTokens;
// Optional properties can be in any order, but font-size and font-family must be last.
- for (const QStringRef &token : tokens) {
+ for (const QStringView &token : tokens) {
if (token.compare(QLatin1String("normal")) == 0) {
if (!(usedTokens & FontStyle) || !(usedTokens & FontVariant) || !(usedTokens & FontWeight)) {
// Could be font-style, font-variant or font-weight.
diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp
index 4860378957..e6ec9e21d9 100644
--- a/src/quick/items/qquickpathview.cpp
+++ b/src/quick/items/qquickpathview.cpp
@@ -1990,7 +1990,7 @@ void QQuickPathView::refill()
if (lcItemViewDelegateLifecycle().isDebugEnabled()) {
QQuickText *text = qmlobject_cast<QQuickText*>(item);
if (text)
- qCDebug(lcItemViewDelegateLifecycle) << "idx" << idx << "@" << pos << ": QQuickText" << text->objectName() << text->text().leftRef(40);
+ qCDebug(lcItemViewDelegateLifecycle) << "idx" << idx << "@" << pos << ": QQuickText" << text->objectName() << QStringView{text->text()}.left(40);
else
qCDebug(lcItemViewDelegateLifecycle) << "idx" << idx << "@" << pos << ":" << item;
}
diff --git a/src/quick/items/qquickscalegrid.cpp b/src/quick/items/qquickscalegrid.cpp
index 23f179be1d..c2288cf220 100644
--- a/src/quick/items/qquickscalegrid.cpp
+++ b/src/quick/items/qquickscalegrid.cpp
@@ -140,8 +140,8 @@ QQuickGridScaledImage::QQuickGridScaledImage(QIODevice *data)
if (colonId <= 0)
return;
- const QStringRef property = line.leftRef(colonId).trimmed();
- QStringRef value = line.midRef(colonId + 1).trimmed();
+ const QStringView property = QStringView{line}.left(colonId).trimmed();
+ QStringView value = QStringView{line}.mid(colonId + 1).trimmed();
if (property == QLatin1String("border.left")) {
l = value.toInt();
@@ -169,9 +169,9 @@ QQuickGridScaledImage::QQuickGridScaledImage(QIODevice *data)
_pix = imgFile;
}
-QQuickBorderImage::TileMode QQuickGridScaledImage::stringToRule(const QStringRef &s)
+QQuickBorderImage::TileMode QQuickGridScaledImage::stringToRule(QStringView s)
{
- QStringRef string = s;
+ QStringView string = s;
if (string.startsWith(QLatin1Char('"')) && string.endsWith(QLatin1Char('"')))
string = string.mid(1, string.size() - 2); // remove leading/trailing quotes.
diff --git a/src/quick/items/qquickscalegrid_p_p.h b/src/quick/items/qquickscalegrid_p_p.h
index 1eb6c05ef1..1e3746161b 100644
--- a/src/quick/items/qquickscalegrid_p_p.h
+++ b/src/quick/items/qquickscalegrid_p_p.h
@@ -122,7 +122,7 @@ public:
QString pixmapUrl() const;
private:
- static QQuickBorderImage::TileMode stringToRule(const QStringRef &);
+ static QQuickBorderImage::TileMode stringToRule(QStringView);
private:
int _l;
diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp
index 30f1e7f405..6a3b2cb277 100644
--- a/src/quick/items/qquicktextcontrol.cpp
+++ b/src/quick/items/qquicktextcontrol.cpp
@@ -1461,7 +1461,7 @@ QVariant QQuickTextControl::inputMethodQuery(Qt::InputMethodQuery property, cons
tmpCursor.movePosition(QTextCursor::NextBlock);
--numBlocks;
}
- result += block.text().midRef(0,localPos);
+ result += QStringView{block.text()}.mid(0,localPos);
return QVariant(result);
}
default:
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index 2f022e6c08..bdbf23bfe2 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -1999,7 +1999,7 @@ QVariant QQuickTextInput::inputMethodQuery(Qt::InputMethodQuery property, const
return QVariant(d->m_text.mid(d->m_cursor));
case Qt::ImTextBeforeCursor:
if (argument.isValid())
- return QVariant(d->m_text.leftRef(d->m_cursor).right(argument.toInt()).toString());
+ return QVariant(QStringView{d->m_text}.left(d->m_cursor).right(argument.toInt()).toString());
return QVariant(d->m_text.left(d->m_cursor));
default:
return QQuickItem::inputMethodQuery(property);
@@ -2041,7 +2041,7 @@ bool QQuickTextInput::isRightToLeft(int start, int end)
qmlWarning(this) << "isRightToLeft(start, end) called with the end property being smaller than the start.";
return false;
} else {
- return text().midRef(start, end - start).isRightToLeft();
+ return QStringView{text()}.mid(start, end - start).isRightToLeft();
}
}
@@ -3728,7 +3728,7 @@ void QQuickTextInputPrivate::internalInsert(const QString &s)
} else {
int remaining = m_maxLength - m_text.length();
if (remaining != 0) {
- const QStringRef remainingStr = s.leftRef(remaining);
+ const QStringView remainingStr = QStringView{s}.left(remaining);
m_text.insert(m_cursor, remainingStr);
for (auto e : remainingStr)
addCommand(Command(Insert, m_cursor++, e, -1, -1));
@@ -4084,14 +4084,14 @@ QString QQuickTextInputPrivate::maskString(uint pos, const QString &str, bool cl
int n = findInMask(i, true, true, str[strIndex]);
if (n != -1) {
if (str.length() != 1 || i == 0 || (i > 0 && (!m_maskData[i-1].separator || m_maskData[i-1].maskChar != str[strIndex]))) {
- s += fill.midRef(i, n-i+1);
+ s += QStringView{fill}.mid(i, n-i+1);
i = n + 1; // update i to find + 1
}
} else {
// search for valid m_blank if not
n = findInMask(i, true, false, str[strIndex]);
if (n != -1) {
- s += fill.midRef(i, n-i);
+ s += QStringView{fill}.mid(i, n-i);
switch (m_maskData[n].caseMode) {
case MaskInputData::Upper:
s += str[strIndex].toUpper();
diff --git a/src/quick/util/qquickanimation.cpp b/src/quick/util/qquickanimation.cpp
index ded353a90a..82d6ca26be 100644
--- a/src/quick/util/qquickanimation.cpp
+++ b/src/quick/util/qquickanimation.cpp
@@ -1010,7 +1010,7 @@ void QQuickScriptActionPrivate::debugAction(QDebug d, int indentLevel) const
QByteArray ind(indentLevel, u' ');
QString exprStr = expr.expression();
int endOfFirstLine = exprStr.indexOf(u'\n');
- d << "\n" << ind.constData() << exprStr.leftRef(endOfFirstLine);
+ d << "\n" << ind.constData() << QStringView{exprStr}.left(endOfFirstLine);
if (endOfFirstLine != -1 && endOfFirstLine < exprStr.length())
d << "...";
}
diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp
index f5d4a54e74..2c20f1c76a 100644
--- a/src/quick/util/qquickglobal.cpp
+++ b/src/quick/util/qquickglobal.cpp
@@ -178,8 +178,8 @@ public:
int index = s.indexOf(QLatin1Char(','));
bool xGood, yGood;
- float xCoord = s.leftRef(index).toFloat(&xGood);
- float yCoord = s.midRef(index + 1).toFloat(&yGood);
+ float xCoord = QStringView{s}.left(index).toFloat(&xGood);
+ float yCoord = QStringView{s}.mid(index + 1).toFloat(&yGood);
if (xGood && yGood) {
if (ok) *ok = true;
@@ -198,9 +198,9 @@ public:
int index2 = s.indexOf(QLatin1Char(','), index+1);
bool xGood, yGood, zGood;
- float xCoord = s.leftRef(index).toFloat(&xGood);
- float yCoord = s.midRef(index + 1, index2 - index - 1).toFloat(&yGood);
- float zCoord = s.midRef(index2 + 1).toFloat(&zGood);
+ float xCoord = QStringView{s}.left(index).toFloat(&xGood);
+ float yCoord = QStringView{s}.mid(index + 1, index2 - index - 1).toFloat(&yGood);
+ float zCoord = QStringView{s}.mid(index2 + 1).toFloat(&zGood);
if (xGood && yGood && zGood) {
if (ok) *ok = true;
@@ -220,10 +220,10 @@ public:
int index3 = s.indexOf(QLatin1Char(','), index2+1);
bool xGood, yGood, zGood, wGood;
- float xCoord = s.leftRef(index).toFloat(&xGood);
- float yCoord = s.midRef(index + 1, index2 - index - 1).toFloat(&yGood);
- float zCoord = s.midRef(index2 + 1, index3 - index2 - 1).toFloat(&zGood);
- float wCoord = s.midRef(index3 + 1).toFloat(&wGood);
+ float xCoord = QStringView{s}.left(index).toFloat(&xGood);
+ float yCoord = QStringView{s}.mid(index + 1, index2 - index - 1).toFloat(&yGood);
+ float zCoord = QStringView{s}.mid(index2 + 1, index3 - index2 - 1).toFloat(&zGood);
+ float wCoord = QStringView{s}.mid(index3 + 1).toFloat(&wGood);
if (xGood && yGood && zGood && wGood) {
if (ok) *ok = true;
@@ -243,10 +243,10 @@ public:
int index3 = s.indexOf(QLatin1Char(','), index2+1);
bool sGood, xGood, yGood, zGood;
- qreal sCoord = s.leftRef(index).toDouble(&sGood);
- qreal xCoord = s.midRef(index+1, index2-index-1).toDouble(&xGood);
- qreal yCoord = s.midRef(index2+1, index3-index2-1).toDouble(&yGood);
- qreal zCoord = s.midRef(index3+1).toDouble(&zGood);
+ qreal sCoord = QStringView{s}.left(index).toDouble(&sGood);
+ qreal xCoord = QStringView{s}.mid(index+1, index2-index-1).toDouble(&xGood);
+ qreal yCoord = QStringView{s}.mid(index2+1, index3-index2-1).toDouble(&yGood);
+ qreal zCoord = QStringView{s}.mid(index3+1).toDouble(&zGood);
if (sGood && xGood && yGood && zGood) {
if (ok) *ok = true;
@@ -263,7 +263,7 @@ public:
if (s.count(QLatin1Char(',')) == 15) {
float matValues[16];
bool vOK = true;
- QStringRef mutableStr(&s);
+ QStringView mutableStr(s);
for (int i = 0; vOK && i < 16; ++i) {
int cidx = mutableStr.indexOf(QLatin1Char(','));
matValues[i] = mutableStr.left(cidx).toDouble(&vOK);
diff --git a/src/quick/util/qquickstategroup.cpp b/src/quick/util/qquickstategroup.cpp
index 2109aafc10..9cb3e26c04 100644
--- a/src/quick/util/qquickstategroup.cpp
+++ b/src/quick/util/qquickstategroup.cpp
@@ -420,26 +420,26 @@ QQuickTransition *QQuickStateGroupPrivate::findTransition(const QString &from, c
const QString fromStateStr = t->fromState();
const QString toStateStr = t->toState();
- QVector<QStringRef> fromState = fromStateStr.splitRef(QLatin1Char(','));
+ auto fromState = QStringView{fromStateStr}.split(QLatin1Char(','));
for (int jj = 0; jj < fromState.count(); ++jj)
fromState[jj] = fromState.at(jj).trimmed();
- QVector<QStringRef> toState = toStateStr.splitRef(QLatin1Char(','));
+ auto toState = QStringView{toStateStr}.split(QLatin1Char(','));
for (int jj = 0; jj < toState.count(); ++jj)
toState[jj] = toState.at(jj).trimmed();
if (ii == 1)
qSwap(fromState, toState);
int tScore = 0;
const QString asterisk = QStringLiteral("*");
- if (fromState.contains(QStringRef(&from)))
+ if (fromState.contains(QStringView(from)))
tScore += 2;
- else if (fromState.contains(QStringRef(&asterisk)))
+ else if (fromState.contains(QStringView(asterisk)))
tScore += 1;
else
continue;
- if (toState.contains(QStringRef(&to)))
+ if (toState.contains(QStringView(to)))
tScore += 2;
- else if (toState.contains(QStringRef(&asterisk)))
+ else if (toState.contains(QStringView(asterisk)))
tScore += 1;
else
continue;
diff --git a/src/quick/util/qquickstyledtext.cpp b/src/quick/util/qquickstyledtext.cpp
index 660852ba83..053aa9823f 100644
--- a/src/quick/util/qquickstyledtext.cpp
+++ b/src/quick/util/qquickstyledtext.cpp
@@ -104,8 +104,8 @@ public:
bool parseUnorderedListAttributes(const QChar *&ch, const QString &textIn);
bool parseAnchorAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format);
void parseImageAttributes(const QChar *&ch, const QString &textIn, QString &textOut);
- QPair<QStringRef,QStringRef> parseAttribute(const QChar *&ch, const QString &textIn);
- QStringRef parseValue(const QChar *&ch, const QString &textIn);
+ QPair<QStringView,QStringView> parseAttribute(const QChar *&ch, const QString &textIn);
+ QStringView parseValue(const QChar *&ch, const QString &textIn);
void setFontSize(int size, QTextCharFormat &format);
inline void skipSpace(const QChar *&ch) {
@@ -298,7 +298,7 @@ void QQuickStyledTextPrivate::appendText(const QString &textIn, int start, int l
{
if (prependSpace)
textOut.append(space);
- textOut.append(QStringRef(&textIn, start, length));
+ textOut.append(QStringView(textIn).mid(start, length));
prependSpace = false;
hasSpace = false;
hasNewLine = false;
@@ -328,7 +328,7 @@ bool QQuickStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn,
if (*ch == greaterThan) {
if (tagLength == 0)
return false;
- QStringRef tag(&textIn, tagStart, tagLength);
+ auto tag = QStringView(textIn).mid(tagStart, tagLength);
const QChar char0 = tag.at(0);
if (char0 == QLatin1Char('b')) {
if (tagLength == 1) {
@@ -437,7 +437,7 @@ bool QQuickStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn,
return false;
} else if (ch->isSpace()) {
// may have params.
- QStringRef tag(&textIn, tagStart, tagLength);
+ auto tag = QStringView(textIn).mid(tagStart, tagLength);
if (tag == QLatin1String("font"))
return parseFontAttributes(ch, textIn, format);
if (tag == QLatin1String("ol")) {
@@ -475,7 +475,7 @@ bool QQuickStyledTextPrivate::parseCloseTag(const QChar *&ch, const QString &tex
if (*ch == greaterThan) {
if (tagLength == 0)
return false;
- QStringRef tag(&textIn, tagStart, tagLength);
+ auto tag = QStringView(textIn).mid(tagStart, tagLength);
const QChar char0 = tag.at(0);
hasNewLine = false;
if (char0 == QLatin1Char('b')) {
@@ -555,7 +555,7 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
int entityLength = 0;
while (!ch->isNull()) {
if (*ch == QLatin1Char(';')) {
- QStringRef entity(&textIn, entityStart, entityLength);
+ auto entity = QStringView(textIn).mid(entityStart, entityLength);
if (entity == QLatin1String("gt"))
textOut += QChar(62);
else if (entity == QLatin1String("lt"))
@@ -568,7 +568,7 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
textOut += QChar(QChar::Nbsp);
return;
} else if (*ch == QLatin1Char(' ')) {
- QStringRef entity(&textIn, entityStart - 1, entityLength + 1);
+ auto entity = QStringView(textIn).mid(entityStart - 1, entityLength + 1);
textOut += entity + *ch;
return;
}
@@ -580,7 +580,7 @@ void QQuickStyledTextPrivate::parseEntity(const QChar *&ch, const QString &textI
bool QQuickStyledTextPrivate::parseFontAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format)
{
bool valid = false;
- QPair<QStringRef,QStringRef> attr;
+ QPair<QStringView,QStringView> attr;
do {
attr = parseAttribute(ch, textIn);
if (attr.first == QLatin1String("color")) {
@@ -608,7 +608,7 @@ bool QQuickStyledTextPrivate::parseOrderedListAttributes(const QChar *&ch, const
listItem.type = Ordered;
listItem.format = Decimal;
- QPair<QStringRef,QStringRef> attr;
+ QPair<QStringView,QStringView> attr;
do {
attr = parseAttribute(ch, textIn);
if (attr.first == QLatin1String("type")) {
@@ -637,7 +637,7 @@ bool QQuickStyledTextPrivate::parseUnorderedListAttributes(const QChar *&ch, con
listItem.type = Unordered;
listItem.format = Bullet;
- QPair<QStringRef,QStringRef> attr;
+ QPair<QStringView,QStringView> attr;
do {
attr = parseAttribute(ch, textIn);
if (attr.first == QLatin1String("type")) {
@@ -657,7 +657,7 @@ bool QQuickStyledTextPrivate::parseAnchorAttributes(const QChar *&ch, const QStr
{
bool valid = false;
- QPair<QStringRef,QStringRef> attr;
+ QPair<QStringView,QStringView> attr;
do {
attr = parseAttribute(ch, textIn);
if (attr.first == QLatin1String("href")) {
@@ -682,7 +682,7 @@ void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QStri
QQuickStyledTextImgTag *image = new QQuickStyledTextImgTag;
image->position = textOut.length() + (trailingSpace ? 0 : 1);
- QPair<QStringRef,QStringRef> attr;
+ QPair<QStringView,QStringView> attr;
do {
attr = parseAttribute(ch, textIn);
if (attr.first == QLatin1String("src")) {
@@ -727,7 +727,7 @@ void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QStri
image->position = textOut.length() + (trailingSpace ? 0 : 1);
imgWidth = image->size.width();
image->offset = -std::fmod(imgWidth, spaceWidth) / 2.0;
- QPair<QStringRef,QStringRef> attr;
+ QPair<QStringView,QStringView> attr;
do {
attr = parseAttribute(ch, textIn);
} while (!ch->isNull() && !attr.first.isEmpty());
@@ -740,7 +740,7 @@ void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QStri
textOut += padding + QLatin1Char(' ');
}
-QPair<QStringRef,QStringRef> QQuickStyledTextPrivate::parseAttribute(const QChar *&ch, const QString &textIn)
+QPair<QStringView,QStringView> QQuickStyledTextPrivate::parseAttribute(const QChar *&ch, const QString &textIn)
{
skipSpace(ch);
@@ -759,10 +759,10 @@ QPair<QStringRef,QStringRef> QQuickStyledTextPrivate::parseAttribute(const QChar
++ch;
if (!attrLength)
break;
- QStringRef attr(&textIn, attrStart, attrLength);
- QStringRef val = parseValue(ch, textIn);
+ auto attr = QStringView(textIn).mid(attrStart, attrLength);
+ QStringView val = parseValue(ch, textIn);
if (!val.isEmpty())
- return QPair<QStringRef,QStringRef>(attr,val);
+ return QPair<QStringView,QStringView>(attr,val);
break;
} else {
++attrLength;
@@ -770,10 +770,10 @@ QPair<QStringRef,QStringRef> QQuickStyledTextPrivate::parseAttribute(const QChar
++ch;
}
- return QPair<QStringRef,QStringRef>();
+ return QPair<QStringView,QStringView>();
}
-QStringRef QQuickStyledTextPrivate::parseValue(const QChar *&ch, const QString &textIn)
+QStringView QQuickStyledTextPrivate::parseValue(const QChar *&ch, const QString &textIn)
{
int valStart = ch - textIn.constData();
int valLength = 0;
@@ -782,10 +782,10 @@ QStringRef QQuickStyledTextPrivate::parseValue(const QChar *&ch, const QString &
++ch;
}
if (ch->isNull())
- return QStringRef();
+ return QStringView();
++ch; // skip quote
- return QStringRef(&textIn, valStart, valLength);
+ return QStringView(textIn).mid(valStart, valLength);
}
QString QQuickStyledTextPrivate::toAlpha(int value, bool upper)
diff --git a/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp b/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp
index 5ff72de0a0..706102e6fe 100644
--- a/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp
+++ b/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp
@@ -178,7 +178,7 @@ void tst_qqmlinfo::types()
//### should this be quoted?
QTest::ignoreMessage(QtInfoMsg, "<Unknown File>: World");
QString str("Hello World");
- QStringRef ref(&str, 6, 5);
+ auto ref = QStringView(str).mid(6, 5);
qmlInfo(nullptr) << ref;
//### should this be quoted?
@@ -189,7 +189,7 @@ void tst_qqmlinfo::types()
void tst_qqmlinfo::chaining()
{
QString str("Hello World");
- QStringRef ref(&str, 6, 5);
+ auto ref = QStringView(str).mid(6, 5);
QTest::ignoreMessage(QtInfoMsg, "<Unknown File>: false 1.1 1.2 15 hello 'b' World \"Qt\" true Quick QUrl(\"http://www.qt-project.org\") ");
qmlInfo(nullptr) << false << ' '
<< 1.1 << ' '
diff --git a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
index b4ebbccb81..02e11f156f 100644
--- a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
+++ b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
@@ -342,7 +342,7 @@ void tst_qqmlparser::stringLiteral()
QVERIFY(expression);
auto *literal = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(expression);
QVERIFY(literal);
- QCOMPARE(literal->value, "hello string");
+ QCOMPARE(literal->value, u"hello string");
QCOMPARE(literal->firstSourceLocation().begin(), 0u);
QCOMPARE(literal->lastSourceLocation().end(), quint32(code.size()));
@@ -361,7 +361,7 @@ void tst_qqmlparser::stringLiteral()
literal = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(binaryExpression->left);
QVERIFY(literal);
- QCOMPARE(literal->value, "hello\n\tstring");
+ QCOMPARE(literal->value, u"hello\n\tstring");
QCOMPARE(literal->firstSourceLocation().begin(), 0u);
QCOMPARE(literal->firstSourceLocation().startLine, 1u);
QCOMPARE(literal->lastSourceLocation().end(), quint32(leftCode.size()));
@@ -369,7 +369,7 @@ void tst_qqmlparser::stringLiteral()
QVERIFY(binaryExpression->right);
literal = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(binaryExpression->right);
QVERIFY(literal);
- QCOMPARE(literal->value, "\nbye");
+ QCOMPARE(literal->value, u"\nbye");
quint32 offset = quint32(leftCode.size() + plusCode.size());
QCOMPARE(literal->firstSourceLocation().begin(), offset);
QCOMPARE(literal->firstSourceLocation().startLine, 1u);
@@ -387,14 +387,14 @@ void tst_qqmlparser::stringLiteral()
literal = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(binaryExpression->left);
QVERIFY(literal);
- QCOMPARE(literal->value, "\nhello\nbye");
+ QCOMPARE(literal->value, u"\nhello\nbye");
QCOMPARE(literal->firstSourceLocation().begin(), 0u);
QCOMPARE(literal->firstSourceLocation().startLine, 1u);
QCOMPARE(literal->lastSourceLocation().end(), leftCode.size());
literal = QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(binaryExpression->right);
QVERIFY(literal);
- QCOMPARE(literal->value, "\nbye");
+ QCOMPARE(literal->value, u"\nbye");
offset = quint32(leftCode.size() + plusCode.size());
QCOMPARE(literal->firstSourceLocation().begin(), offset);
QCOMPARE(literal->lastSourceLocation().startLine, 3u);
@@ -479,7 +479,7 @@ void tst_qqmlparser::noSubstitutionTemplateLiteral()
auto *literal = QQmlJS::AST::cast<QQmlJS::AST::TemplateLiteral *>(expression);
QVERIFY(literal);
- QCOMPARE(literal->value, "hello template");
+ QCOMPARE(literal->value, u"hello template");
QCOMPARE(literal->firstSourceLocation().begin(), 0u);
QCOMPARE(literal->lastSourceLocation().end(), quint32(code.size()));
}
@@ -696,7 +696,7 @@ void tst_qqmlparser::annotations_data()
for (const QString &file: qAsConst(files)) {
auto fileNameStart = file.lastIndexOf(QDir::separator());
- QStringRef fileName(&file, fileNameStart, file.length()-fileNameStart);
+ auto fileName = QStringView(file).mid(fileNameStart, file.length()-fileNameStart);
auto ref=std::find_if(refFiles.constBegin(),refFiles.constEnd(), [fileName](const QString &s){ return s.endsWith(fileName); });
if (ref != refFiles.constEnd())
QTest::newRow(qPrintable(file)) << file << *ref;
diff --git a/tests/auto/shared/qqmljsastdumper.cpp b/tests/auto/shared/qqmljsastdumper.cpp
index 34c31a294c..83560f48c2 100644
--- a/tests/auto/shared/qqmljsastdumper.cpp
+++ b/tests/auto/shared/qqmljsastdumper.cpp
@@ -212,7 +212,7 @@ QString AstDumper::qs(const char *s) {
return qs(QLatin1String(s));
}
-QString AstDumper::qs(const QStringRef &s) {
+QString AstDumper::qs(QStringView s) {
return qs(s.toString());
}
diff --git a/tests/auto/shared/qqmljsastdumper.h b/tests/auto/shared/qqmljsastdumper.h
index 4abaea7fba..839dd99942 100644
--- a/tests/auto/shared/qqmljsastdumper.h
+++ b/tests/auto/shared/qqmljsastdumper.h
@@ -89,7 +89,7 @@ public:
QString qs(const QString &s);
QString qs(const char *s);
- QString qs(const QStringRef &s);
+ QString qs(QStringView s);
QString loc(const SourceLocation &s);
diff --git a/tools/qmlcachegen/resourcefilter.cpp b/tools/qmlcachegen/resourcefilter.cpp
index 261102dcbe..37c027c365 100644
--- a/tools/qmlcachegen/resourcefilter.cpp
+++ b/tools/qmlcachegen/resourcefilter.cpp
@@ -61,7 +61,7 @@ int filterResourceFile(const QString &input, const QString &output)
while (!reader.atEnd()) {
switch (reader.readNext()) {
case QXmlStreamReader::StartDocument: {
- QStringRef version = reader.documentVersion();
+ QStringView version = reader.documentVersion();
if (!version.isEmpty())
writer.writeStartDocument(version.toString());
else
diff --git a/tools/qmleasing/splineeditor.cpp b/tools/qmleasing/splineeditor.cpp
index 1426a1e107..99c161d475 100644
--- a/tools/qmleasing/splineeditor.cpp
+++ b/tools/qmleasing/splineeditor.cpp
@@ -675,12 +675,12 @@ void SplineEditor::setEasingCurve(const QString &code)
if (m_block)
return;
if (code.startsWith(QLatin1Char('[')) && code.endsWith(QLatin1Char(']'))) {
- const QStringRef cleanCode(&code, 1, code.size() - 2);
+ const auto cleanCode = QStringView(code).mid(1, code.size() - 2);
const auto stringList = cleanCode.split(QLatin1Char(','), Qt::SkipEmptyParts);
if (stringList.count() >= 6 && (stringList.count() % 6 == 0)) {
QVector<qreal> realList;
realList.reserve(stringList.count());
- for (const QStringRef &string : stringList) {
+ for (const QStringView &string : stringList) {
bool ok;
realList.append(string.toDouble(&ok));
if (!ok)
diff --git a/tools/qmlimportscanner/main.cpp b/tools/qmlimportscanner/main.cpp
index f9f3cd90cf..348328f6a4 100644
--- a/tools/qmlimportscanner/main.cpp
+++ b/tools/qmlimportscanner/main.cpp
@@ -254,7 +254,7 @@ QVariantList findPathsForModuleImports(const QVariantList &imports)
if (plugininfo.contains(dependenciesLiteral())) {
const QStringList dependencies = plugininfo.value(dependenciesLiteral()).toStringList();
for (const QString &line : dependencies) {
- const auto dep = line.splitRef(QLatin1Char(' '));
+ const auto dep = QStringView{line}.split(QLatin1Char(' '));
QVariantMap depImport;
depImport[typeLiteral()] = moduleLiteral();
depImport[nameLiteral()] = dep[0].toString();
diff --git a/tools/qmllint/checkidentifiers.cpp b/tools/qmllint/checkidentifiers.cpp
index 0bd5c8127e..32c2fa4d79 100644
--- a/tools/qmllint/checkidentifiers.cpp
+++ b/tools/qmllint/checkidentifiers.cpp
@@ -37,21 +37,21 @@ class IssueLocationWithContext
public:
IssueLocationWithContext(const QString &code, const QQmlJS::SourceLocation &location) {
int before = std::max(0,code.lastIndexOf(QLatin1Char('\n'), location.offset));
- m_beforeText = code.midRef(before + 1, int(location.offset - (before + 1)));
- m_issueText = code.midRef(location.offset, location.length);
+ m_beforeText = QStringView{code}.mid(before + 1, int(location.offset - (before + 1)));
+ m_issueText = QStringView{code}.mid(location.offset, location.length);
int after = code.indexOf(QLatin1Char('\n'), int(location.offset + location.length));
- m_afterText = code.midRef(int(location.offset + location.length),
+ m_afterText = QStringView{code}.mid(int(location.offset + location.length),
int(after - (location.offset+location.length)));
}
- QStringRef beforeText() const { return m_beforeText; }
- QStringRef issueText() const { return m_issueText; }
- QStringRef afterText() const { return m_afterText; }
+ QStringView beforeText() const { return m_beforeText; }
+ QStringView issueText() const { return m_issueText; }
+ QStringView afterText() const { return m_afterText; }
private:
- QStringRef m_beforeText;
- QStringRef m_issueText;
- QStringRef m_afterText;
+ QStringView m_beforeText;
+ QStringView m_issueText;
+ QStringView m_afterText;
};
static void writeWarning(ColorOutput *out)
diff --git a/tools/qmllint/findwarnings.cpp b/tools/qmllint/findwarnings.cpp
index 59b2fc90dc..cc8a323112 100644
--- a/tools/qmllint/findwarnings.cpp
+++ b/tools/qmllint/findwarnings.cpp
@@ -317,7 +317,7 @@ void FindWarningVisitor::importFileOrDirectory(const QString &fileOrDirectory,
}
}
-void FindWarningVisitor::importExportedNames(const QStringRef &prefix, QString name)
+void FindWarningVisitor::importExportedNames(QStringView prefix, QString name)
{
QList<ScopeTree::ConstPtr> scopes;
for (;;) {
@@ -780,7 +780,7 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiObjectBinding *uiob)
QString name {};
auto id = uiob->qualifiedTypeNameId;
- QStringRef prefix = uiob->qualifiedTypeNameId->name;
+ QStringView prefix = uiob->qualifiedTypeNameId->name;
while (id) {
name += id->name.toString() + QLatin1Char('.');
id = id->next;
@@ -816,7 +816,7 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiObjectDefinition *uiod)
QString name {};
auto id = uiod->qualifiedTypeNameId;
- QStringRef prefix = uiod->qualifiedTypeNameId->name;
+ QStringView prefix = uiod->qualifiedTypeNameId->name;
while (id) {
name += id->name.toString() + QLatin1Char('.');
id = id->next;
diff --git a/tools/qmllint/findwarnings.h b/tools/qmllint/findwarnings.h
index 6e5f3859cc..ee019b440d 100644
--- a/tools/qmllint/findwarnings.h
+++ b/tools/qmllint/findwarnings.h
@@ -106,7 +106,7 @@ private:
ScopeTree::Ptr localFile2ScopeTree(const QString &filePath);
void importFileOrDirectory(const QString &directory, const QString &prefix);
- void importExportedNames(const QStringRef &prefix, QString name);
+ void importExportedNames(QStringView prefix, QString name);
void parseHeaders(QQmlJS::AST::UiHeaderItemList *headers);
ScopeTree::Ptr parseProgram(QQmlJS::AST::Program *program, const QString &name);
diff --git a/tools/qmlprofiler/qmlprofilerapplication.cpp b/tools/qmlprofiler/qmlprofilerapplication.cpp
index 7c92f428ae..d91ef191e5 100644
--- a/tools/qmlprofiler/qmlprofilerapplication.cpp
+++ b/tools/qmlprofiler/qmlprofilerapplication.cpp
@@ -354,7 +354,7 @@ bool QmlProfilerApplication::checkOutputFile(PendingRequest pending)
void QmlProfilerApplication::userCommand(const QString &command)
{
- auto args = command.splitRef(QChar::Space, Qt::SkipEmptyParts);
+ auto args = QStringView{command}.split(QChar::Space, Qt::SkipEmptyParts);
if (args.isEmpty()) {
prompt();
return;
diff --git a/tools/qmlprofiler/qmlprofilerdata.cpp b/tools/qmlprofiler/qmlprofilerdata.cpp
index 9ec143975e..8803170ff2 100644
--- a/tools/qmlprofiler/qmlprofilerdata.cpp
+++ b/tools/qmlprofiler/qmlprofilerdata.cpp
@@ -198,7 +198,7 @@ void QmlProfilerData::addEventType(const QQmlProfilerEventType &type)
break;
case PixmapCacheEvent: {
const QString filePath = QUrl(type.location().filename()).path();
- displayName = filePath.midRef(filePath.lastIndexOf(QLatin1Char('/')) + 1)
+ displayName = QStringView{filePath}.mid(filePath.lastIndexOf(QLatin1Char('/')) + 1)
+ QLatin1Char(':') + QString::number(type.detailType());
break;
}
@@ -218,7 +218,7 @@ void QmlProfilerData::addEventType(const QQmlProfilerEventType &type)
displayName = QString::fromLatin1("Unknown");
} else {
const QString filePath = QUrl(eventLocation.filename()).path();
- displayName = filePath.midRef(
+ displayName = QStringView{filePath}.mid(
filePath.lastIndexOf(QLatin1Char('/')) + 1) +
QLatin1Char(':') + QString::number(eventLocation.line());
}
diff --git a/tools/shared/componentversion.cpp b/tools/shared/componentversion.cpp
index 95403ec15f..5019cdcc33 100644
--- a/tools/shared/componentversion.cpp
+++ b/tools/shared/componentversion.cpp
@@ -35,10 +35,10 @@ ComponentVersion::ComponentVersion(const QString &versionString)
if (dotIdx == -1)
return;
bool ok = false;
- const int maybeMajor = versionString.leftRef(dotIdx).toInt(&ok);
+ const int maybeMajor = QStringView{versionString}.left(dotIdx).toInt(&ok);
if (!ok)
return;
- const int maybeMinor = versionString.midRef(dotIdx + 1).toInt(&ok);
+ const int maybeMinor = QStringView{versionString}.mid(dotIdx + 1).toInt(&ok);
if (!ok)
return;
m_version = QTypeRevision::fromVersion(maybeMajor, maybeMinor);