Do not pass QStringView by const reference

That's what the documentation says:

  https://doc.qt.io/qt-6/qstringview.html#details

Change-Id: I0b41fc4abad1601c0ed416a505534cf7ae7633e1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Kai Köhne
2021-06-15 20:25:49 +02:00
committed by Kai Koehne
parent 4bfcea22bf
commit bf04c98c1c
22 changed files with 68 additions and 68 deletions

View File

@@ -33,7 +33,7 @@ QT_QML_BEGIN_NAMESPACE
using namespace LanguageUtils;
static int parseInt(const QStringView &str, bool *ok)
static int parseInt(QStringView str, bool *ok)
{
int pos = 0;
int number = 0;

View File

@@ -318,12 +318,12 @@ class QML_PARSER_EXPORT UiQualifiedId: public Node
public:
QMLJS_DECLARE_AST_NODE(UiQualifiedId)
UiQualifiedId(const QStringView &name)
UiQualifiedId(QStringView name)
: next(this)
, name(name)
{ kind = K; }
UiQualifiedId(UiQualifiedId *previous, const QStringView &name)
UiQualifiedId(UiQualifiedId *previous, QStringView name)
: name(name)
{
kind = K;
@@ -513,7 +513,7 @@ class QML_PARSER_EXPORT IdentifierExpression: public LeftHandSideExpression
public:
QMLJS_DECLARE_AST_NODE(IdentifierExpression)
IdentifierExpression(const QStringView &n)
IdentifierExpression(QStringView n)
: name(n)
{
kind = K;
@@ -658,7 +658,7 @@ class QML_PARSER_EXPORT StringLiteral : public LeftHandSideExpression
public:
QMLJS_DECLARE_AST_NODE(StringLiteral)
StringLiteral(const QStringView &v)
StringLiteral(QStringView v)
: value(v)
{
kind = K;
@@ -682,7 +682,7 @@ class QML_PARSER_EXPORT TemplateLiteral : public LeftHandSideExpression
public:
QMLJS_DECLARE_AST_NODE(TemplateLiteral)
TemplateLiteral(const QStringView &str, const QStringView &raw, ExpressionNode *e)
TemplateLiteral(QStringView str, QStringView raw, ExpressionNode *e)
: value(str)
, rawValue(raw)
, expression(e)
@@ -712,7 +712,7 @@ class QML_PARSER_EXPORT RegExpLiteral: public LeftHandSideExpression
public:
QMLJS_DECLARE_AST_NODE(RegExpLiteral)
RegExpLiteral(const QStringView &p, int f)
RegExpLiteral(QStringView p, int f)
: pattern(p)
, flags(f)
{
@@ -907,7 +907,7 @@ public:
: initializer(i), type(t)
{ kind = K; }
PatternElement(const QStringView &n,
PatternElement(QStringView n,
TypeAnnotation *typeAnnotation = nullptr,
ExpressionNode *i = nullptr,
Type t = Binding)
@@ -1007,7 +1007,7 @@ public:
: PatternElement(i, t), name(name)
{ kind = K; }
PatternProperty(PropertyName *name, const QStringView &n, ExpressionNode *i = nullptr)
PatternProperty(PropertyName *name, QStringView n, ExpressionNode *i = nullptr)
: PatternElement(n, /*type annotation*/ nullptr, i)
, name(name)
{ kind = K; }
@@ -1078,7 +1078,7 @@ class QML_PARSER_EXPORT IdentifierPropertyName: public PropertyName
public:
QMLJS_DECLARE_AST_NODE(IdentifierPropertyName)
IdentifierPropertyName(const QStringView &n)
IdentifierPropertyName(QStringView n)
: id(n)
{
kind = K;
@@ -1097,7 +1097,7 @@ class QML_PARSER_EXPORT StringLiteralPropertyName: public PropertyName
public:
QMLJS_DECLARE_AST_NODE(StringLiteralPropertyName)
StringLiteralPropertyName(const QStringView &n)
StringLiteralPropertyName(QStringView n)
: id(n)
{
kind = K;
@@ -1180,7 +1180,7 @@ class QML_PARSER_EXPORT FieldMemberExpression: public LeftHandSideExpression
public:
QMLJS_DECLARE_AST_NODE(FieldMemberExpression)
FieldMemberExpression(ExpressionNode *b, const QStringView &n)
FieldMemberExpression(ExpressionNode *b, QStringView n)
: base(b)
, name(n)
{
@@ -1972,7 +1972,7 @@ class QML_PARSER_EXPORT ContinueStatement: public Statement
public:
QMLJS_DECLARE_AST_NODE(ContinueStatement)
ContinueStatement(const QStringView &l = QStringView())
ContinueStatement(QStringView l = QStringView())
: label(l)
{
kind = K;
@@ -1998,7 +1998,7 @@ class QML_PARSER_EXPORT BreakStatement: public Statement
public:
QMLJS_DECLARE_AST_NODE(BreakStatement)
BreakStatement(const QStringView &l)
BreakStatement(QStringView l)
: label(l)
{
kind = K;
@@ -2229,7 +2229,7 @@ class QML_PARSER_EXPORT LabelledStatement: public Statement
public:
QMLJS_DECLARE_AST_NODE(LabelledStatement)
LabelledStatement(const QStringView &l, Statement *stmt)
LabelledStatement(QStringView l, Statement *stmt)
: label(l)
, statement(stmt)
{
@@ -2364,7 +2364,7 @@ class QML_PARSER_EXPORT FunctionExpression: public ExpressionNode
public:
QMLJS_DECLARE_AST_NODE(FunctionExpression)
FunctionExpression(const QStringView &n,
FunctionExpression(QStringView n,
FormalParameterList *f,
StatementList *b,
TypeAnnotation *typeAnnotation = nullptr)
@@ -2405,7 +2405,7 @@ class QML_PARSER_EXPORT FunctionDeclaration: public FunctionExpression
public:
QMLJS_DECLARE_AST_NODE(FunctionDeclaration)
FunctionDeclaration(const QStringView &n,
FunctionDeclaration(QStringView n,
FormalParameterList *f,
StatementList *b,
TypeAnnotation *typeAnnotation = nullptr)
@@ -2506,7 +2506,7 @@ class QML_PARSER_EXPORT ClassExpression : public ExpressionNode
public:
QMLJS_DECLARE_AST_NODE(ClassExpression)
ClassExpression(const QStringView &n, ExpressionNode *heritage, ClassElementList *elements)
ClassExpression(QStringView n, ExpressionNode *heritage, ClassElementList *elements)
: name(n)
, heritage(heritage)
, elements(elements)
@@ -2538,7 +2538,7 @@ class QML_PARSER_EXPORT ClassDeclaration: public ClassExpression
public:
QMLJS_DECLARE_AST_NODE(ClassDeclaration)
ClassDeclaration(const QStringView &n, ExpressionNode *heritage, ClassElementList *elements)
ClassDeclaration(QStringView n, ExpressionNode *heritage, ClassElementList *elements)
: ClassExpression(n, heritage, elements)
{
kind = K; }
@@ -2610,13 +2610,13 @@ class QML_PARSER_EXPORT ImportSpecifier: public Node
public:
QMLJS_DECLARE_AST_NODE(ImportSpecifier)
ImportSpecifier(const QStringView &importedBinding)
ImportSpecifier(QStringView importedBinding)
: importedBinding(importedBinding)
{
kind = K;
}
ImportSpecifier(const QStringView &identifier, const QStringView &importedBinding)
ImportSpecifier(QStringView identifier, QStringView importedBinding)
: identifier(identifier)
, importedBinding(importedBinding)
{
@@ -2718,7 +2718,7 @@ class QML_PARSER_EXPORT NameSpaceImport: public Node
public:
QMLJS_DECLARE_AST_NODE(NameSpaceImport)
NameSpaceImport(const QStringView &importedBinding)
NameSpaceImport(QStringView importedBinding)
: importedBinding(importedBinding)
{
kind = K;
@@ -2742,7 +2742,7 @@ class QML_PARSER_EXPORT ImportClause: public Node
public:
QMLJS_DECLARE_AST_NODE(ImportClause)
ImportClause(const QStringView &importedDefaultBinding)
ImportClause(QStringView importedDefaultBinding)
: importedDefaultBinding(importedDefaultBinding)
{
kind = K;
@@ -2760,14 +2760,14 @@ public:
kind = K;
}
ImportClause(const QStringView &importedDefaultBinding, NameSpaceImport *nameSpaceImport)
ImportClause(QStringView importedDefaultBinding, NameSpaceImport *nameSpaceImport)
: importedDefaultBinding(importedDefaultBinding)
, nameSpaceImport(nameSpaceImport)
{
kind = K;
}
ImportClause(const QStringView &importedDefaultBinding, NamedImports *namedImports)
ImportClause(QStringView importedDefaultBinding, NamedImports *namedImports)
: importedDefaultBinding(importedDefaultBinding)
, namedImports(namedImports)
{
@@ -2793,7 +2793,7 @@ class QML_PARSER_EXPORT FromClause: public Node
public:
QMLJS_DECLARE_AST_NODE(FromClause)
FromClause(const QStringView &moduleSpecifier)
FromClause(QStringView moduleSpecifier)
: moduleSpecifier(moduleSpecifier)
{
kind = K;
@@ -2824,7 +2824,7 @@ public:
kind = K;
}
ImportDeclaration(const QStringView &moduleSpecifier)
ImportDeclaration(QStringView moduleSpecifier)
: moduleSpecifier(moduleSpecifier)
{
kind = K;
@@ -2851,14 +2851,14 @@ class QML_PARSER_EXPORT ExportSpecifier: public Node
public:
QMLJS_DECLARE_AST_NODE(ExportSpecifier)
ExportSpecifier(const QStringView &identifier)
ExportSpecifier(QStringView identifier)
: identifier(identifier)
, exportedIdentifier(identifier)
{
kind = K;
}
ExportSpecifier(const QStringView &identifier, const QStringView &exportedIdentifier)
ExportSpecifier(QStringView identifier, QStringView exportedIdentifier)
: identifier(identifier)
, exportedIdentifier(exportedIdentifier)
{
@@ -3047,7 +3047,7 @@ class QML_PARSER_EXPORT UiImport: public Node
public:
QMLJS_DECLARE_AST_NODE(UiImport)
UiImport(const QStringView &fileName)
UiImport(QStringView fileName)
: fileName(fileName)
, importUri(nullptr)
{ kind = K; }
@@ -3319,14 +3319,14 @@ class QML_PARSER_EXPORT UiParameterList: public Node
public:
QMLJS_DECLARE_AST_NODE(UiParameterList)
UiParameterList(UiQualifiedId *t, const QStringView &n)
UiParameterList(UiQualifiedId *t, QStringView n)
: type(t)
, name(n)
, next(this)
{
kind = K; }
UiParameterList(UiParameterList *previous, UiQualifiedId *t, const QStringView &n)
UiParameterList(UiParameterList *previous, UiQualifiedId *t, QStringView n)
: type(t)
, name(n)
{
@@ -3368,7 +3368,7 @@ class QML_PARSER_EXPORT UiPublicMember: public UiObjectMember
public:
QMLJS_DECLARE_AST_NODE(UiPublicMember)
UiPublicMember(UiQualifiedId *memberType, const QStringView &name)
UiPublicMember(UiQualifiedId *memberType, QStringView name)
: type(Property)
, memberType(memberType)
, name(name)
@@ -3379,7 +3379,7 @@ public:
, parameters(nullptr)
{ kind = K; }
UiPublicMember(UiQualifiedId *memberType, const QStringView &name, Statement *statement)
UiPublicMember(UiQualifiedId *memberType, QStringView name, Statement *statement)
: type(Property)
, memberType(memberType)
, name(name)
@@ -3468,7 +3468,7 @@ class QML_PARSER_EXPORT UiInlineComponent: public UiObjectMember
public:
QMLJS_DECLARE_AST_NODE(UiInlineComponent)
UiInlineComponent(const QStringView &inlineComponentName, UiObjectDefinition *inlineComponent)
UiInlineComponent(QStringView inlineComponentName, UiObjectDefinition *inlineComponent)
: name(inlineComponentName)
, component(inlineComponent)
{ kind = K; }
@@ -3615,13 +3615,13 @@ class QML_PARSER_EXPORT UiEnumMemberList: public Node
{
QMLJS_DECLARE_AST_NODE(UiEnumMemberList)
public:
UiEnumMemberList(const QStringView &member, double v = 0.0)
UiEnumMemberList(QStringView member, double v = 0.0)
: next(this)
, member(member)
, value(v)
{ kind = K; }
UiEnumMemberList(UiEnumMemberList *previous, const QStringView &member)
UiEnumMemberList(UiEnumMemberList *previous, QStringView member)
: member(member)
{
kind = K;
@@ -3630,7 +3630,7 @@ public:
value = previous->value + 1;
}
UiEnumMemberList(UiEnumMemberList *previous, const QStringView &member, double v)
UiEnumMemberList(UiEnumMemberList *previous, QStringView member, double v)
: member(member)
, value(v)
{
@@ -3670,7 +3670,7 @@ class QML_PARSER_EXPORT UiEnumDeclaration: public UiObjectMember
public:
QMLJS_DECLARE_AST_NODE(UiEnumDeclaration)
UiEnumDeclaration(const QStringView &name, UiEnumMemberList *members)
UiEnumDeclaration(QStringView name, UiEnumMemberList *members)
: name(name)
, members(members)
{ kind = K; }

View File

@@ -1063,7 +1063,7 @@ void ObjectValue::setMember(const QString &name, const Value *value)
m_members[name].value = value;
}
void ObjectValue::setMember(const QStringView &name, const Value *value)
void ObjectValue::setMember(QStringView name, const Value *value)
{
m_members[name.toString()].value = value;
}

View File

@@ -507,7 +507,7 @@ public:
virtual void processMembers(MemberProcessor *processor) const;
virtual void setMember(const QString &name, const Value *value);
virtual void setMember(const QStringView &name, const Value *value);
virtual void setMember(QStringView name, const Value *value);
virtual void setPropertyInfo(const QString &name, const PropertyInfo &propertyInfo);
virtual void removeMember(const QString &name);

View File

@@ -108,7 +108,7 @@ static const char matchMaskAttributeC[] = "mask";
*/
MimeTypeParserBase::ParseState MimeTypeParserBase::nextState(ParseState currentState,
const QStringView &startElement)
QStringView startElement)
{
switch (currentState) {
case ParseBeginning:

View File

@@ -91,7 +91,7 @@ private:
ParseError
};
static ParseState nextState(ParseState currentState, const QStringView &startElement);
static ParseState nextState(ParseState currentState, QStringView startElement);
};

View File

@@ -334,7 +334,7 @@ void AbstractSettings::readDocumentation()
QStringList keys;
while (!(xml.atEnd() || xml.hasError())) {
if (xml.readNext() == QXmlStreamReader::StartElement) {
const QStringView &name = xml.name();
QStringView name = xml.name();
if (name == QLatin1String(Constants::DOCUMENTATION_XMLENTRY)) {
keys.clear();
} else if (name == QLatin1String(Constants::DOCUMENTATION_XMLKEY)) {

View File

@@ -454,7 +454,7 @@ bool ClangCompletionAssistProcessor::accepts() const
&& tokens.at(1).kind() == T_IDENTIFIER) {
const QString &line = tc.block().text();
const Token &idToken = tokens.at(1);
const QStringView &identifier = Utils::midView(line,
QStringView identifier = Utils::midView(line,
idToken.utf16charsBegin(),
idToken.utf16chars());
if (identifier == QLatin1String("include")

View File

@@ -242,7 +242,7 @@ struct Attribute {
};
}
static QList<Attribute> toAttributes(const QStringView &attributes)
static QList<Attribute> toAttributes(QStringView attributes)
{
QList<Attribute> result;
const QRegularExpression att("\\s+([a-zA-Z]+)\\s*=\\s*('.*?'|\".*?\")");
@@ -260,8 +260,8 @@ static QList<Attribute> toAttributes(const QStringView &attributes)
return result;
}
static inline ParseState nextOpeningState(ParseState current, const QStringView &tagView,
const QStringView &attributesView)
static inline ParseState nextOpeningState(ParseState current, QStringView tagView,
QStringView attributesView)
{
switch (current) {
case OutSideTable:
@@ -300,7 +300,7 @@ static inline ParseState nextOpeningState(ParseState current, const QStringView
return ParseError;
}
static inline ParseState nextClosingState(ParseState current, const QStringView &element)
static inline ParseState nextClosingState(ParseState current, QStringView element)
{
switch (current) {
case OutSideTable:

View File

@@ -278,7 +278,7 @@ void CppHighlighter::setLanguageFeatures(const LanguageFeatures &languageFeature
}
}
bool CppHighlighter::isPPKeyword(const QStringView &text) const
bool CppHighlighter::isPPKeyword(QStringView text) const
{
switch (text.length())
{
@@ -370,7 +370,7 @@ void CppHighlighter::highlightWord(QStringView word, int position, int length)
}
}
bool CppHighlighter::highlightRawStringLiteral(const QStringView &_text, const Token &tk)
bool CppHighlighter::highlightRawStringLiteral(QStringView _text, const Token &tk)
{
// Step one: Does the lexer think this is a raw string literal?
switch (tk.kind()) {

View File

@@ -47,12 +47,12 @@ public:
private:
void highlightWord(QStringView word, int position, int length);
bool highlightRawStringLiteral(const QStringView &text, const CPlusPlus::Token &tk);
bool highlightRawStringLiteral(QStringView text, const CPlusPlus::Token &tk);
void highlightDoxygenComment(const QString &text, int position,
int length);
bool isPPKeyword(const QStringView &text) const;
bool isPPKeyword(QStringView text) const;
private:
CPlusPlus::LanguageFeatures m_languageFeatures = CPlusPlus::LanguageFeatures::defaultFeatures();

View File

@@ -880,7 +880,7 @@ bool InternalCppCompletionAssistProcessor::accepts() const
&& tokens.at(1).kind() == T_IDENTIFIER) {
const QString &line = tc.block().text();
const Token &idToken = tokens.at(1);
const QStringView &identifier = idToken.utf16charsEnd() > line.size()
QStringView identifier = idToken.utf16charsEnd() > line.size()
? QStringView(line).mid(
idToken.utf16charsBegin())
: QStringView(line)

View File

@@ -1039,7 +1039,7 @@ void CdbEngine::runCommand(const DebuggerCommand &dbgCmd)
}
QTC_CHECK(argumentSplitPos == arguments.size());
int tokenPart = splittedArguments.size();
for (const QStringView &part : qAsConst(splittedArguments))
for (QStringView part : qAsConst(splittedArguments))
str << prefix << " -t " << token << '.' << --tokenPart << ' ' << part << '\n';
} else {
cmd = prefix;

View File

@@ -42,7 +42,7 @@ public:
StringInputStream &operator<<(char a) { m_target.append(a); return *this; }
StringInputStream &operator<<(const char *a) { m_target.append(QString::fromUtf8(a)); return *this; }
StringInputStream &operator<<(const QString &a) { m_target.append(a); return *this; }
StringInputStream &operator<<(const QStringView &a)
StringInputStream &operator<<(QStringView a)
{
m_target.append(a.toString());
return *this;

View File

@@ -260,7 +260,7 @@ void GlslHighlighter::highlightLine(const QString &text, int position, int lengt
}
}
bool GlslHighlighter::isPPKeyword(const QStringView &text) const
bool GlslHighlighter::isPPKeyword(QStringView text) const
{
switch (text.length())
{

View File

@@ -40,7 +40,7 @@ public:
protected:
void highlightBlock(const QString &text) override;
void highlightLine(const QString &text, int position, int length, const QTextCharFormat &format);
bool isPPKeyword(const QStringView &text) const;
bool isPPKeyword(QStringView text) const;
};
} // namespace Internal

View File

@@ -308,7 +308,7 @@ static inline QMap<QString, QString> attributesToStringMap(const QXmlStreamAttri
}
// Switch parser state depending on opening element name.
static ParseState nextOpeningState(ParseState in, const QStringView &name)
static ParseState nextOpeningState(ParseState in, QStringView name)
{
switch (in) {
case ParseBeginning:
@@ -375,7 +375,7 @@ static ParseState nextOpeningState(ParseState in, const QStringView &name)
}
// Switch parser state depending on closing element name.
static ParseState nextClosingState(ParseState in, const QStringView &name)
static ParseState nextClosingState(ParseState in, QStringView name)
{
switch (in) {
case ParseBeginning:

View File

@@ -121,7 +121,7 @@ static bool shouldInsertNewline(const QTextCursor &tc)
return false;
}
static bool isCompleteStringLiteral(const QStringView &text)
static bool isCompleteStringLiteral(QStringView text)
{
if (text.length() < 2)
return false;

View File

@@ -417,7 +417,7 @@ protected:
{
UiQualifiedId *id = qualifiedTypeNameId(member);
if (id) {
const QStringView &name = id->name;
QStringView name = id->name;
if (!name.isEmpty() && name.at(0).isUpper())
return true;
}
@@ -435,7 +435,7 @@ protected:
else if (script->qualifiedId->next)
return false;
const QStringView &propertyName = script->qualifiedId->name;
QStringView propertyName = script->qualifiedId->name;
if (propertyName == QLatin1String("id"))
return true;

View File

@@ -202,7 +202,7 @@ void QmlJSHighlighter::highlightBlock(const QString &text)
onBlockEnd(m_scanner.state());
}
bool QmlJSHighlighter::maybeQmlKeyword(const QStringView &text) const
bool QmlJSHighlighter::maybeQmlKeyword(QStringView text) const
{
if (text.isEmpty())
return false;
@@ -228,7 +228,7 @@ bool QmlJSHighlighter::maybeQmlKeyword(const QStringView &text) const
return false;
}
bool QmlJSHighlighter::maybeQmlBuiltinType(const QStringView &text) const
bool QmlJSHighlighter::maybeQmlBuiltinType(QStringView text) const
{
if (text.isEmpty())
return false;

View File

@@ -56,8 +56,8 @@ protected:
void onOpeningParenthesis(QChar parenthesis, int pos, bool atStart);
void onClosingParenthesis(QChar parenthesis, int pos, bool atEnd);
bool maybeQmlKeyword(const QStringView &text) const;
bool maybeQmlBuiltinType(const QStringView &text) const;
bool maybeQmlKeyword(QStringView text) const;
bool maybeQmlBuiltinType(QStringView text) const;
private:
bool m_qmlEnabled;

View File

@@ -239,7 +239,7 @@ protected:
m_scopeBuilder.pop();
}
void processName(const QStringView &name, SourceLocation location)
void processName(QStringView name, SourceLocation location)
{
if (name.isEmpty())
return;