Qt::mightBeRichText: use QVLA more
to reduce allocations Change-Id: I59e131bcdd626f740a73e621b926f4c7dad4738a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
c0e5464d28
commit
7b4c8dd8c2
@ -98,10 +98,10 @@ bool Qt::mightBeRichText(const QString& text)
|
|||||||
if (open < text.size() && text.at(open) == u'<') {
|
if (open < text.size() && text.at(open) == u'<') {
|
||||||
const int close = text.indexOf(u'>', open);
|
const int close = text.indexOf(u'>', open);
|
||||||
if (close > -1) {
|
if (close > -1) {
|
||||||
QString tag;
|
QVarLengthArray<char16_t> tag;
|
||||||
for (int i = open+1; i < close; ++i) {
|
for (qsizetype i = open + 1; i < close; ++i) {
|
||||||
if (text[i].isDigit() || text[i].isLetter())
|
if (text[i].isDigit() || text[i].isLetter())
|
||||||
tag += text[i];
|
tag.append(text[i].toLower().unicode());
|
||||||
else if (!tag.isEmpty() && text[i].isSpace())
|
else if (!tag.isEmpty() && text[i].isSpace())
|
||||||
break;
|
break;
|
||||||
else if (!tag.isEmpty() && text[i] == u'/' && i + 1 == close)
|
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
|
return false; // that's not a tag
|
||||||
}
|
}
|
||||||
#ifndef QT_NO_TEXTHTMLPARSER
|
#ifndef QT_NO_TEXTHTMLPARSER
|
||||||
return QTextHtmlParser::lookupElement(std::move(tag).toLower()) != -1;
|
return QTextHtmlParser::lookupElement(tag) != -1;
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif // QT_NO_TEXTHTMLPARSER
|
#endif // QT_NO_TEXTHTMLPARSER
|
||||||
|
Loading…
x
Reference in New Issue
Block a user