Made Regex static and const, removed dist

Signed-off-by: SabrePenguin <lknofczynski@gmail.com>
This commit is contained in:
SabrePenguin 2024-05-01 13:00:55 -04:00 committed by Trial97
parent f43873a8ba
commit fa2c2a7c85
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318

View File

@ -213,14 +213,14 @@ QPair<QString, QString> StringUtils::splitFirst(const QString& s, const QRegular
return qMakePair(left, right);
}
static const QRegularExpression ulMatcher("<\\s*/\\s*ul\\s*>");
QString StringUtils::htmlListPatch(QString htmlStr)
{
QRegularExpression match("<\\s/\\s*ul\\s*>");
int pos = htmlStr.indexOf(match);
int imgPos, dist;
int pos = htmlStr.indexOf(ulMatcher);
int imgPos;
while (pos != -1) {
dist = htmlStr.indexOf(">", pos) - pos + 1; // Get the size of the </ul> tag. Add one for zeroeth index
pos = pos + dist;
pos = htmlStr.indexOf(">", pos) + 1; // Get the size of the </ul> tag. Add one for zeroeth index
imgPos = htmlStr.indexOf("<img ", pos);
if (imgPos == -1)
break; // no image after the tag
@ -230,7 +230,7 @@ QString StringUtils::htmlListPatch(QString htmlStr)
if (textBetween.isEmpty())
htmlStr.insert(pos, "<br>");
pos = htmlStr.indexOf(match, pos);
pos = htmlStr.indexOf(ulMatcher, pos);
}
return htmlStr;
}