QUrl: optimise setHost for the common case
authorThiago Macieira <thiago.macieira@intel.com>
Wed, 19 Oct 2011 18:33:31 +0000 (20:33 +0200)
committerQt by Nokia <qt-info@nokia.com>
Thu, 29 Mar 2012 23:19:59 +0000 (01:19 +0200)
Change-Id: Ib667557268ebf75cb796ddd716b337ca24b466ad
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
src/corelib/io/qurl.cpp

index b8ab9df..36411a0 100644 (file)
@@ -1587,12 +1587,13 @@ QString QUrl::password(ComponentFormattingOptions options) const
 void QUrl::setHost(const QString &host)
 {
     detach();
-    if (host.contains(QLatin1Char(':')) || host.contains(QLatin1String("%3a"), Qt::CaseInsensitive))
+    if (d->setHost(host, 0, host.length())) {
+        if (host.isNull())
+            d->sectionIsPresent &= ~QUrlPrivate::Host;
+    } else {
+        // setHost failed, it might be IPv6 or IPvFuture in need of bracketing
         d->setHost(QLatin1Char('[') + host + QLatin1Char(']'), 0, host.length() + 2);
-    else
-        d->setHost(host, 0, host.length());
-    if (host.isNull())
-        d->sectionIsPresent &= ~QUrlPrivate::Host;
+    }
 }
 
 /*!