mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-27 23:14:31 +00:00
Cache QRegExp in misc::parseHtmlLinks()
This commit should improve performance when user navigating through torrent list using up/down keys. A scrolling through all the list (276 torrents) took: Total wall time: 18.813s Total CPU time: 3.210s misc::parseHtmlLinks(): 0.096s misc::parseHtmlLinks() is 8th most hottest function on this use case.
This commit is contained in:
parent
9023232653
commit
5986c1dbc9
@ -505,7 +505,8 @@ bool misc::isUrl(const QString &s)
|
||||
QString misc::parseHtmlLinks(const QString &raw_text)
|
||||
{
|
||||
QString result = raw_text;
|
||||
QRegExp reURL("(\\s|^)" //start with whitespace or beginning of line
|
||||
static QRegExp reURL(
|
||||
"(\\s|^)" //start with whitespace or beginning of line
|
||||
"("
|
||||
"(" //case 1 -- URL with scheme
|
||||
"(http(s?))\\://" //start with scheme
|
||||
@ -556,7 +557,7 @@ QString misc::parseHtmlLinks(const QString &raw_text)
|
||||
result.replace(reURL, "\\1<a href=\"\\2\">\\2</a>");
|
||||
|
||||
// Capture links without scheme
|
||||
QRegExp reNoScheme("<a\\s+href=\"(?!http(s?))([a-zA-Z0-9\\?%=&/_\\.-:#]+)\\s*\">");
|
||||
static QRegExp reNoScheme("<a\\s+href=\"(?!http(s?))([a-zA-Z0-9\\?%=&/_\\.-:#]+)\\s*\">");
|
||||
result.replace(reNoScheme, "<a href=\"http://\\1\">");
|
||||
|
||||
return result;
|
||||
|
Loading…
x
Reference in New Issue
Block a user