From 7b4c8dd8c28ac47e1b8601fc79a4dc333b0e739d Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Thu, 7 Sep 2023 22:43:55 +0300 Subject: [PATCH] Qt::mightBeRichText: use QVLA more to reduce allocations Change-Id: I59e131bcdd626f740a73e621b926f4c7dad4738a Reviewed-by: Edward Welbourne --- src/gui/text/qtextdocument.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 151798b2e69..e8f04e5d095 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -98,10 +98,10 @@ bool Qt::mightBeRichText(const QString& text) if (open < text.size() && text.at(open) == u'<') { const int close = text.indexOf(u'>', open); if (close > -1) { - QString tag; - for (int i = open+1; i < close; ++i) { + QVarLengthArray tag; + for (qsizetype i = open + 1; i < close; ++i) { if (text[i].isDigit() || text[i].isLetter()) - tag += text[i]; + tag.append(text[i].toLower().unicode()); else if (!tag.isEmpty() && text[i].isSpace()) break; else if (!tag.isEmpty() && text[i] == u'/' && i + 1 == close) @@ -110,7 +110,7 @@ bool Qt::mightBeRichText(const QString& text) return false; // that's not a tag } #ifndef QT_NO_TEXTHTMLPARSER - return QTextHtmlParser::lookupElement(std::move(tag).toLower()) != -1; + return QTextHtmlParser::lookupElement(tag) != -1; #else return false; #endif // QT_NO_TEXTHTMLPARSER