From 328c0cf809a437a9875e485d2da12a2da22cd11b Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 15 Jun 2020 17:39:32 +0200 Subject: [PATCH] CppTool: Avoid a use of QStringRef Change-Id: I2a82bad7d91e059915526f0cf7b89f0d8367463a Reviewed-by: Christian Kandeler --- src/plugins/cppeditor/cpphighlighter.cpp | 2 +- src/plugins/cpptools/builtineditordocumentprocessor.cpp | 2 +- src/plugins/cpptools/cpptoolsreuse.cpp | 2 +- src/plugins/cpptools/cpptoolsreuse.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/cppeditor/cpphighlighter.cpp b/src/plugins/cppeditor/cpphighlighter.cpp index d862ea3c2c5..6cfa94ee52b 100644 --- a/src/plugins/cppeditor/cpphighlighter.cpp +++ b/src/plugins/cppeditor/cpphighlighter.cpp @@ -195,7 +195,7 @@ void CppHighlighter::highlightBlock(const QString &text) } else if (tk.isKeyword() || (m_languageFeatures.qtKeywordsEnabled - && CppTools::isQtKeyword(text.midRef(tk.utf16charsBegin(), tk.utf16chars()))) + && CppTools::isQtKeyword(QStringView{text}.mid(tk.utf16charsBegin(), tk.utf16chars()))) || (m_languageFeatures.objCEnabled && tk.isObjCAtKeyword())) { setFormat(tk.utf16charsBegin(), tk.utf16chars(), formatForCategory(C_KEYWORD)); } else if (tk.isPrimitiveType()) { diff --git a/src/plugins/cpptools/builtineditordocumentprocessor.cpp b/src/plugins/cpptools/builtineditordocumentprocessor.cpp index 408c6e7b15a..ce35d95b77c 100644 --- a/src/plugins/cpptools/builtineditordocumentprocessor.cpp +++ b/src/plugins/cpptools/builtineditordocumentprocessor.cpp @@ -123,7 +123,7 @@ CppTools::CheckSymbols *createHighlighter(const CPlusPlus::Document::Ptr &doc, const QString name = macro.macro().nameToQString(); //Filter out QtKeywords - if (features.qtKeywordsEnabled && isQtKeyword(QStringRef(&name))) + if (features.qtKeywordsEnabled && isQtKeyword(name)) continue; SimpleLexer tokenize; diff --git a/src/plugins/cpptools/cpptoolsreuse.cpp b/src/plugins/cpptools/cpptoolsreuse.cpp index d98febf6972..e1c4a9e6d0c 100644 --- a/src/plugins/cpptools/cpptoolsreuse.cpp +++ b/src/plugins/cpptools/cpptoolsreuse.cpp @@ -214,7 +214,7 @@ bool isValidIdentifier(const QString &s) return true; } -bool isQtKeyword(const QStringRef &text) +bool isQtKeyword(QStringView text) { switch (text.length()) { case 4: diff --git a/src/plugins/cpptools/cpptoolsreuse.h b/src/plugins/cpptools/cpptoolsreuse.h index afab4a46845..00472979b09 100644 --- a/src/plugins/cpptools/cpptoolsreuse.h +++ b/src/plugins/cpptools/cpptoolsreuse.h @@ -52,7 +52,7 @@ namespace CppTools { void CPPTOOLS_EXPORT moveCursorToEndOfIdentifier(QTextCursor *tc); void CPPTOOLS_EXPORT moveCursorToStartOfIdentifier(QTextCursor *tc); -bool CPPTOOLS_EXPORT isQtKeyword(const QStringRef &text); +bool CPPTOOLS_EXPORT isQtKeyword(QStringView text); bool CPPTOOLS_EXPORT isValidAsciiIdentifierChar(const QChar &ch); bool CPPTOOLS_EXPORT isValidFirstIdentifierChar(const QChar &ch);