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/compiler/qv4compilerscanfunctions.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/qml/compiler/qv4compilerscanfunctions.cpp') 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")); } } -- cgit v1.2.3