From 1b10ce6a08edbc2ac7e8fd7e97e3fc691f2081df Mon Sep 17 00:00:00 2001 From: Karsten Heimrich Date: Tue, 16 Jun 2020 10:23:19 +0200 Subject: Port QtDeclarative from QStringRef to QStringView MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-84319 Change-Id: I2dcfb8a2db98282c7a1acdad1e6f4f949f26df15 Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Shawn Rutledge Reviewed-by: Timur Pocheptsov --- src/qml/qml/ftw/qhashedstring_p.h | 4 ++-- src/qml/qml/ftw/qstringhash_p.h | 4 ++-- src/qml/qml/qqmlerror.cpp | 4 ++-- src/qml/qml/qqmlfile.cpp | 4 ++-- src/qml/qml/qqmlimport.cpp | 14 +++++++------- src/qml/qml/qqmlinfo.h | 2 +- src/qml/qml/qqmlmetatype.cpp | 2 +- src/qml/qml/qqmlproperty.cpp | 12 ++++++------ src/qml/qml/qqmlpropertycache.cpp | 8 ++++---- src/qml/qml/qqmlpropertycache_p.h | 4 ++-- src/qml/qml/qqmlpropertycachecreator.cpp | 2 +- src/qml/qml/qqmlstringconverters.cpp | 16 ++++++++-------- src/qml/qml/qqmltype.cpp | 2 +- src/qml/qml/qqmltype_p.h | 2 +- src/qml/qml/qqmltypecompiler.cpp | 22 +++++++++++----------- src/qml/qml/qqmltypecompiler_p.h | 8 ++++---- src/qml/qml/qqmltypedata.cpp | 6 +++--- src/qml/qml/qqmlxmlhttprequest.cpp | 2 +- 18 files changed, 59 insertions(+), 59 deletions(-) (limited to 'src/qml/qml') 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 struct HashedForm {}; template<> struct HashedForm { typedef QHashedString Type; }; -template<> struct HashedForm { typedef QHashedStringRef Type; }; +template<> struct HashedForm { typedef QHashedStringRef Type; }; template<> struct HashedForm { typedef const QHashedString &Type; }; template<> struct HashedForm { typedef const QV4::String *Type; }; template<> struct HashedForm { typedef const QV4::String *Type; }; @@ -265,7 +265,7 @@ class QStringHashBase { public: static HashedForm::Type hashedString(const QString &s) { return QHashedString(s);} - static HashedForm::Type hashedString(const QStringRef &s) { return QHashedStringRef(s.constData(), s.size());} + static HashedForm::Type hashedString(QStringView s) { return QHashedStringRef(s.constData(), s.size());} static HashedForm::Type hashedString(const QHashedString &s) { return s; } static HashedForm::Type hashedString(QV4::String *s) { return s; } static HashedForm::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 typeNameCache = context ? context->imports() : nullptr; QObject *currentObject = obj; - QVector path; - QStringRef terminal(&name); + QList 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 &context, QQmlPropertyData *local) { - return qQmlPropertyCacheProperty(engine, obj, name, context, local); + return qQmlPropertyCacheProperty(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 &, QQmlPropertyData *); static QQmlPropertyData *property(QJSEngine *, QObject *, const QLatin1String &, const QQmlRefPointer &, QQmlPropertyData *); @@ -196,7 +196,7 @@ public: const QQmlRefPointer &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 ¶m : 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 &roots) { m_componentRoots = roots; } const QVector &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 &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 &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(type.location.line)); error.setColumn(qmlConvertSourceCoordinate(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) -- cgit v1.2.3