OSDN Git Service

avoid two character lookups in qIsEffectiveTLD() function
authorIvailo Monev <xakepa10@laimg.moc>
Tue, 26 Nov 2019 18:20:58 +0000 (18:20 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Tue, 26 Nov 2019 18:20:58 +0000 (18:20 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/core/io/qtldurl.cpp

index ca160db..81e0ee4 100644 (file)
@@ -84,8 +84,9 @@ Q_CORE_EXPORT bool qIsEffectiveTLD(const QString &domain)
     if (containsTLDEntry(domain))
         return true;
 
-    if (domain.contains(QLatin1Char('.'))) {
-        int count = domain.size() - domain.indexOf(QLatin1Char('.'));
+    const int dotindex = domain.indexOf(QLatin1Char('.'));
+    if (dotindex > 0) {
+        int count = (domain.size() - dotindex);
         QString wildCardDomain;
         wildCardDomain.reserve(count + 1);
         wildCardDomain.append(QLatin1Char('*'));