summaryrefslogtreecommitdiff
path: root/src/urlbar/urlresolver.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-05-16 22:58:02 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-05-16 22:58:02 +0200
commitb9c705c040a8faad2a3516967cd03a9ab7366e0c (patch)
tree0d9b6dea56d752b56af63a826ea9b7244b06a0b6 /src/urlbar/urlresolver.cpp
parentMerge commit 'refs/merge-requests/2263' of git://gitorious.org/rekonq/mainlin... (diff)
parentperformance improvement: build one static regexp instead of several in the is... (diff)
downloadrekonq-b9c705c040a8faad2a3516967cd03a9ab7366e0c.tar.xz
Merge commit 'refs/merge-requests/2264' of git://gitorious.org/rekonq/mainline into m2264
Diffstat (limited to 'src/urlbar/urlresolver.cpp')
-rw-r--r--src/urlbar/urlresolver.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp
index 840fd78f..1376ca2c 100644
--- a/src/urlbar/urlresolver.cpp
+++ b/src/urlbar/urlresolver.cpp
@@ -60,9 +60,32 @@ bool UrlSearchItem::operator==(const UrlSearchItem &i) const
}
+QRegExp* UrlResolver::_browseRegexp = NULL;
+
+
UrlResolver::UrlResolver(const QString &typedUrl)
: _typedString(typedUrl.trimmed())
{
+ if (_browseRegexp==NULL)
+ {
+ QString protocol = "^(http://|https://|file://|ftp://)";
+
+ QString ipv4 = "^0*([1-9]?\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.0*([1-9]?\\d|1\\d\\d|2[0-4]\\d|25[0-5])"\
+ "\\.0*([1-9]?\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.0*([1-9]?\\d|1\\d\\d|2[0-4]\\d|25[0-5])";
+
+ QString ipv6 = "^([0-9a-fA-F]{4}|0)(\\:([0-9a-fA-F]{4}|0)){7}";
+
+ QString address = "[\\d\\w-.]+\\.(a[cdefgilmnoqrstuwz]|b[abdefghijmnorstvwyz]|"\
+ "c[acdfghiklmnoruvxyz]|d[ejkmnoz]|e[ceghrst]|f[ijkmnor]|g[abdefghilmnpqrstuwy]|"\
+ "h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|"\
+ "m[acdghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eouw]|"\
+ "s[abcdeghijklmnortuvyz]|t[cdfghjkmnoprtvwz]|u[augkmsyz]|v[aceginu]|w[fs]|"\
+ "y[etu]|z[amw]|aero|arpa|biz|com|coop|edu|info|int|gov|mil|museum|name|net|org|"\
+ "pro)";
+
+ _browseRegexp = new QRegExp("(" + protocol + ")|(" + address + ")|(" + ipv6 + ")|(" + ipv4 +")");
+ }
+
}
@@ -76,7 +99,7 @@ UrlSearchList UrlResolver::orderedSearchItems()
UrlSearchList list;
- if(isHttp())
+ if(_browseRegexp->indexIn(_typedString) != -1)
{
list << qurlFromUserInputResolution();
list << webSearchesResolution();
@@ -135,29 +158,6 @@ UrlSearchList UrlResolver::orderedSearchItems()
}
-bool UrlResolver::isHttp()
-{
- QString ipv4 = "^0*([1-9]?\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.0*([1-9]?\\d|1\\d\\d|2[0-4]\\d|25[0-5])"\
- "\\.0*([1-9]?\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.0*([1-9]?\\d|1\\d\\d|2[0-4]\\d|25[0-5])";
-
- QString ipv6 = "^([0-9a-fA-F]{4}|0)(\\:([0-9a-fA-F]{4}|0)){7}";
-
- QString address = "[\\d\\w-.]+\\.(a[cdefgilmnoqrstuwz]|b[abdefghijmnorstvwyz]|"\
- "c[acdfghiklmnoruvxyz]|d[ejkmnoz]|e[ceghrst]|f[ijkmnor]|g[abdefghilmnpqrstuwy]|"\
- "h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|"\
- "m[acdghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eouw]|"\
- "s[abcdeghijklmnortuvyz]|t[cdfghjkmnoprtvwz]|u[augkmsyz]|v[aceginu]|w[fs]|"\
- "y[etu]|z[amw]|aero|arpa|biz|com|coop|edu|info|int|gov|mil|museum|name|net|org|"\
- "pro)";
-
- return _typedString.startsWith( QL1S("http://") )
- || _typedString.startsWith( QL1S("https://") )
- || (QRegExp(address, Qt::CaseInsensitive).indexIn(_typedString) != -1)
- || (QRegExp(ipv4, Qt::CaseInsensitive).indexIn(_typedString) != -1)
- || (QRegExp(ipv6, Qt::CaseInsensitive).indexIn(_typedString) != -1);
-}
-
-
//////////////////////////////////////////////////////////////////////////
// PRIVATE ENGINES