From c772438470494713ca62f352b8b1950c863a3d41 Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Fri, 13 Sep 2019 08:03:02 +0200 Subject: [PATCH] GIT_SILENT: minor qstring optimization --- src/lib/adblock/adblockrule.cpp | 10 +++++----- src/lib/cookies/cookiejar.cpp | 4 ++-- src/lib/cookies/cookiemanager.cpp | 2 +- src/lib/opensearch/opensearchengine.cpp | 8 ++++---- src/lib/other/siteinfo.cpp | 2 +- src/lib/other/siteinfowidget.cpp | 2 +- src/lib/preferences/acceptlanguage.cpp | 4 ++-- src/lib/tools/buttonwithmenu.cpp | 2 +- src/lib/tools/certificateinfowidget.cpp | 4 ++-- src/lib/tools/closedtabsmanager.cpp | 2 +- src/lib/tools/qztools.cpp | 8 ++++---- src/lib/tools/treewidget.cpp | 4 ++-- src/plugins/FlashCookieManager/fcm_dialog.cpp | 2 +- src/plugins/FlashCookieManager/fcm_plugin.cpp | 2 +- src/plugins/PIM/PIM_handler.cpp | 2 +- src/plugins/StatusBarIcons/sbi_networkicon.cpp | 2 +- src/plugins/TabManager/tldextractor/tldextractor.cpp | 4 ++-- 17 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/lib/adblock/adblockrule.cpp b/src/lib/adblock/adblockrule.cpp index 5d51e905b..5251b5ea6 100644 --- a/src/lib/adblock/adblockrule.cpp +++ b/src/lib/adblock/adblockrule.cpp @@ -451,7 +451,7 @@ void AdBlockRule::parseFilter() // Exception always starts with @@ if (parsedLine.startsWith(QL1S("@@"))) { m_isException = true; - parsedLine = parsedLine.mid(2); + parsedLine.remove(0, 2); } // Parse all options following $ char @@ -550,12 +550,12 @@ void AdBlockRule::parseFilter() return; } - parsedLine = parsedLine.left(optionsIndex); + parsedLine.truncate(optionsIndex); } // Rule is classic regexp if (parsedLine.startsWith(QL1C('/')) && parsedLine.endsWith(QL1C('/'))) { - parsedLine = parsedLine.mid(1); + parsedLine.remove(0, 1); parsedLine = parsedLine.left(parsedLine.size() - 1); m_type = RegExpMatchRule; @@ -570,7 +570,7 @@ void AdBlockRule::parseFilter() // Remove starting and ending wildcards (*) if (parsedLine.startsWith(QL1C('*'))) { - parsedLine = parsedLine.mid(1); + parsedLine.remove(0, 1); } if (parsedLine.endsWith(QL1C('*'))) { @@ -579,7 +579,7 @@ void AdBlockRule::parseFilter() // We can use fast string matching for domain here if (filterIsOnlyDomain(parsedLine)) { - parsedLine = parsedLine.mid(2); + parsedLine.remove(0, 2); parsedLine = parsedLine.left(parsedLine.size() - 1); m_type = DomainMatchRule; diff --git a/src/lib/cookies/cookiejar.cpp b/src/lib/cookies/cookiejar.cpp index 9a52aff85..6ed557393 100644 --- a/src/lib/cookies/cookiejar.cpp +++ b/src/lib/cookies/cookiejar.cpp @@ -98,11 +98,11 @@ bool CookieJar::matchDomain(QString cookieDomain, QString siteDomain) const // Remove leading dot if (cookieDomain.startsWith(QLatin1Char('.'))) { - cookieDomain = cookieDomain.mid(1); + cookieDomain.remove(0, 1); } if (siteDomain.startsWith(QLatin1Char('.'))) { - siteDomain = siteDomain.mid(1); + siteDomain.remove(0, 1); } return QzTools::matchDomain(cookieDomain, siteDomain); diff --git a/src/lib/cookies/cookiemanager.cpp b/src/lib/cookies/cookiemanager.cpp index 49d782488..1aa21a9b7 100644 --- a/src/lib/cookies/cookiemanager.cpp +++ b/src/lib/cookies/cookiemanager.cpp @@ -222,7 +222,7 @@ QString CookieManager::cookieDomain(const QNetworkCookie &cookie) const { QString domain = cookie.domain(); if (domain.startsWith(QLatin1Char('.'))) { - domain = domain.mid(1); + domain.remove(0, 1); } return domain; } diff --git a/src/lib/opensearch/opensearchengine.cpp b/src/lib/opensearch/opensearchengine.cpp index 092f0f1ed..a83c5af81 100644 --- a/src/lib/opensearch/opensearchengine.cpp +++ b/src/lib/opensearch/opensearchengine.cpp @@ -122,7 +122,7 @@ QString OpenSearchEngine::parseTemplate(const QString &searchTerm, const QString { QString language = QLocale().name(); // Simple conversion to RFC 3066. - language = language.replace(QLatin1Char('_'), QLatin1Char('-')); + language.replace(QLatin1Char('_'), QLatin1Char('-')); QString result = searchTemplate; result.replace(QLatin1String("{count}"), QLatin1String("20")); @@ -540,7 +540,7 @@ QByteArray OpenSearchEngine::getSuggestionsParameters() Parameters::const_iterator end = m_suggestionsParameters.constEnd(); Parameters::const_iterator i = m_suggestionsParameters.constBegin(); for (; i != end; ++i) { - parameters.append(i->first + QLatin1String("=") + i->second); + parameters.append(i->first + QLatin1Char('=') + i->second); } QByteArray data = parameters.join(QLatin1String("&")).toUtf8(); @@ -576,7 +576,7 @@ void OpenSearchEngine::requestSuggestions(const QString &searchTerm) Parameters::const_iterator end = m_suggestionsParameters.constEnd(); Parameters::const_iterator i = m_suggestionsParameters.constBegin(); for (; i != end; ++i) { - parameters.append(i->first + QLatin1String("=") + i->second); + parameters.append(i->first + QLatin1Char('=') + i->second); } QByteArray data = parameters.join(QLatin1String("&")).toUtf8(); @@ -613,7 +613,7 @@ void OpenSearchEngine::requestSearchResults(const QString &searchTerm) Parameters::const_iterator end = m_searchParameters.constEnd(); Parameters::const_iterator i = m_searchParameters.constBegin(); for (; i != end; ++i) { - parameters.append(i->first + QLatin1String("=") + i->second); + parameters.append(i->first + QLatin1Char('=') + i->second); } data = parameters.join(QLatin1String("&")).toUtf8(); diff --git a/src/lib/other/siteinfo.cpp b/src/lib/other/siteinfo.cpp index a3471bb76..16498b85e 100644 --- a/src/lib/other/siteinfo.cpp +++ b/src/lib/other/siteinfo.cpp @@ -190,7 +190,7 @@ void SiteInfo::saveImage() QString imageFileName = QzTools::getFileNameFromUrl(QUrl(item->text(1))); int index = imageFileName.lastIndexOf(QLatin1Char('.')); if (index != -1) { - imageFileName = imageFileName.left(index); + imageFileName.truncate(index); imageFileName.append(QL1S(".png")); } diff --git a/src/lib/other/siteinfowidget.cpp b/src/lib/other/siteinfowidget.cpp index 4e8dde030..12d024cd8 100644 --- a/src/lib/other/siteinfowidget.cpp +++ b/src/lib/other/siteinfowidget.cpp @@ -61,7 +61,7 @@ SiteInfoWidget::SiteInfoWidget(BrowserWindow* window, QWidget* parent) if (query.next()) { int count = query.value(0).toInt(); if (count > 3) { - ui->historyLabel->setText(tr("This is your %1 visit of this site.").arg(QString::number(count) + ".")); + ui->historyLabel->setText(tr("This is your %1 visit of this site.").arg(QString::number(count) + QLatin1Char('.'))); ui->historyIcon->setPixmap(QPixmap(":/icons/locationbar/visit3.png")); } else if (count == 0) { diff --git a/src/lib/preferences/acceptlanguage.cpp b/src/lib/preferences/acceptlanguage.cpp index 631b2fcb1..a8c4bc81b 100644 --- a/src/lib/preferences/acceptlanguage.cpp +++ b/src/lib/preferences/acceptlanguage.cpp @@ -55,7 +55,7 @@ QStringList AcceptLanguage::defaultLanguage() QByteArray AcceptLanguage::generateHeader(const QStringList &langs) { - if (langs.count() == 0) { + if (langs.isEmpty()) { return QByteArray(); } @@ -126,7 +126,7 @@ QStringList AcceptLanguage::expand(const QLocale::Language &language) languageString = QString(QLatin1String("%1/%2 [%3]")) .arg(QLocale::languageToString(language)) .arg(QLocale::countryToString(countries.at(j))) - .arg(QLocale(language, countries.at(j)).name().split(QLatin1Char('_')).join(QLatin1String("-")).toLower()); + .arg(QLocale(language, countries.at(j)).name().split(QLatin1Char('_')).join(QLatin1Char('-')).toLower()); } if (!allLanguages.contains(languageString)) { diff --git a/src/lib/tools/buttonwithmenu.cpp b/src/lib/tools/buttonwithmenu.cpp index 5cf2ff6ed..5c78823b6 100644 --- a/src/lib/tools/buttonwithmenu.cpp +++ b/src/lib/tools/buttonwithmenu.cpp @@ -90,7 +90,7 @@ void ButtonWithMenu::removeItem(const Item &item) m_items.remove(index); - if (m_items.count() == 0) { + if (m_items.isEmpty()) { setIcon(QIcon()); return; } diff --git a/src/lib/tools/certificateinfowidget.cpp b/src/lib/tools/certificateinfowidget.cpp index d84efdbf5..cb680cbbc 100644 --- a/src/lib/tools/certificateinfowidget.cpp +++ b/src/lib/tools/certificateinfowidget.cpp @@ -279,8 +279,8 @@ QString CertificateInfoWidget::clearCertSpecialSymbols(const QString &string) n.replace(QLatin1String("\\xC2\\xBD"), QLatin1String("1/2")); // one half n.replace(QLatin1String("\\xC2\\xBE"), QLatin1String("3/4")); // three quarters n.replace(QLatin1String("\\xCA\\xBF"), QLatin1String("\\x27")); // c-single quote - n.replace(QLatin1String("\\xCC\\xA8"), QString()); // modifier - under curve - n.replace(QLatin1String("\\xCC\\xB1"), QString()); // modifier - under line + n.remove(QLatin1String("\\xCC\\xA8")); // modifier - under curve + n.remove(QLatin1String("\\xCC\\xB1")); // modifier - under line return n; } diff --git a/src/lib/tools/closedtabsmanager.cpp b/src/lib/tools/closedtabsmanager.cpp index 21f5a9f64..6ab6ac274 100644 --- a/src/lib/tools/closedtabsmanager.cpp +++ b/src/lib/tools/closedtabsmanager.cpp @@ -32,7 +32,7 @@ void ClosedTabsManager::saveTab(WebTab *tab) } // Don't save empty tab - if (tab->url().isEmpty() && tab->history()->items().count() == 0) { + if (tab->url().isEmpty() && tab->history()->items().isEmpty()) { return; } diff --git a/src/lib/tools/qztools.cpp b/src/lib/tools/qztools.cpp index 499b22503..661a282ca 100644 --- a/src/lib/tools/qztools.cpp +++ b/src/lib/tools/qztools.cpp @@ -379,16 +379,16 @@ QString QzTools::fileSizeToString(qint64 size) double _size = size / 1024.0; // KB if (_size < 1000) { - return QString::number(_size > 1 ? _size : 1, 'f', 0) + " " + QObject::tr("KB"); + return QString::number(_size > 1 ? _size : 1, 'f', 0) + QLatin1Char(' ') + QObject::tr("KB"); } _size /= 1024; // MB if (_size < 1000) { - return QString::number(_size, 'f', 1) + " " + QObject::tr("MB"); + return QString::number(_size, 'f', 1) + QLatin1Char(' ') + QObject::tr("MB"); } _size /= 1024; // GB - return QString::number(_size, 'f', 2) + " " + QObject::tr("GB"); + return QString::number(_size, 'f', 2) + QLatin1Char(' ') + QObject::tr("GB"); } QPixmap QzTools::createPixmapForSite(const QIcon &icon, const QString &title, const QString &url) @@ -848,7 +848,7 @@ bool QzTools::startExternalProcess(const QString &executable, const QString &arg if (!success) { QString info = ""; info = info.arg(QObject::tr("Executable: "), executable, - QObject::tr("Arguments: "), arguments.join(QLatin1String(" "))); + QObject::tr("Arguments: "), arguments.join(QLatin1Char(' '))); QMessageBox::critical(0, QObject::tr("Cannot start external program"), QObject::tr("Cannot start external program! %1").arg(info)); diff --git a/src/lib/tools/treewidget.cpp b/src/lib/tools/treewidget.cpp index 16dad56e4..59723705f 100644 --- a/src/lib/tools/treewidget.cpp +++ b/src/lib/tools/treewidget.cpp @@ -143,7 +143,7 @@ void TreeWidget::filterString(const QString &string) bool TreeWidget::appendToParentItem(const QString &parentText, QTreeWidgetItem* item) { QList list = findItems(parentText, Qt::MatchExactly); - if (list.count() == 0) { + if (list.isEmpty()) { return false; } QTreeWidgetItem* parentItem = list.at(0); @@ -170,7 +170,7 @@ bool TreeWidget::appendToParentItem(QTreeWidgetItem* parent, QTreeWidgetItem* it bool TreeWidget::prependToParentItem(const QString &parentText, QTreeWidgetItem* item) { QList list = findItems(parentText, Qt::MatchExactly); - if (list.count() == 0) { + if (list.isEmpty()) { return false; } QTreeWidgetItem* parentItem = list.at(0); diff --git a/src/plugins/FlashCookieManager/fcm_dialog.cpp b/src/plugins/FlashCookieManager/fcm_dialog.cpp index 213f5f395..0855a4787 100644 --- a/src/plugins/FlashCookieManager/fcm_dialog.cpp +++ b/src/plugins/FlashCookieManager/fcm_dialog.cpp @@ -215,7 +215,7 @@ void FCM_Dialog::refreshFlashCookiesTree() QString cookieOrigin = flashCookie.origin; if (cookieOrigin.startsWith(QLatin1Char('.'))) { - cookieOrigin = cookieOrigin.mid(1); + cookieOrigin.remove(0, 1); } QTreeWidgetItem* findParent = hash.value(cookieOrigin); diff --git a/src/plugins/FlashCookieManager/fcm_plugin.cpp b/src/plugins/FlashCookieManager/fcm_plugin.cpp index 7603a87f2..161641f12 100644 --- a/src/plugins/FlashCookieManager/fcm_plugin.cpp +++ b/src/plugins/FlashCookieManager/fcm_plugin.cpp @@ -449,7 +449,7 @@ QString FCM_Plugin::extractOriginFrom(const QString &path) if (index == -1) { return tr("!other"); } - origin = origin.remove(index, origin.size()); + origin.remove(index, origin.size()); if (origin == QL1S("localhost") || origin == QL1S("local")) { origin = QL1S("!localhost"); } diff --git a/src/plugins/PIM/PIM_handler.cpp b/src/plugins/PIM/PIM_handler.cpp index ad6601601..90d11b393 100644 --- a/src/plugins/PIM/PIM_handler.cpp +++ b/src/plugins/PIM/PIM_handler.cpp @@ -115,7 +115,7 @@ void PIM_Handler::populateWebViewMenu(QMenu* menu, WebView* view, const WebHitTe pimMenu->setIcon(QIcon(":/PIM/data/PIM.png")); if (!m_allInfo[PI_FirstName].isEmpty() && !m_allInfo[PI_LastName].isEmpty()) { - const QString fullname = m_allInfo[PI_FirstName] + " " + m_allInfo[PI_LastName]; + const QString fullname = m_allInfo[PI_FirstName] + QLatin1Char(' ') + m_allInfo[PI_LastName]; QAction* action = pimMenu->addAction(fullname, this, &PIM_Handler::pimInsert); action->setData(fullname); } diff --git a/src/plugins/StatusBarIcons/sbi_networkicon.cpp b/src/plugins/StatusBarIcons/sbi_networkicon.cpp index 80a72f987..1fc72d68a 100644 --- a/src/plugins/StatusBarIcons/sbi_networkicon.cpp +++ b/src/plugins/StatusBarIcons/sbi_networkicon.cpp @@ -77,7 +77,7 @@ void SBI_NetworkIcon::showMenu(const QPoint &pos) act->setChecked(it.value() == SBINetManager->currentProxy()); } - if (proxyMenu->actions().count() == 0) { + if (proxyMenu->actions().isEmpty()) { proxyMenu->addAction(tr("Empty"))->setEnabled(false); } diff --git a/src/plugins/TabManager/tldextractor/tldextractor.cpp b/src/plugins/TabManager/tldextractor/tldextractor.cpp index 830dc3ee9..8f5df7e77 100644 --- a/src/plugins/TabManager/tldextractor/tldextractor.cpp +++ b/src/plugins/TabManager/tldextractor/tldextractor.cpp @@ -87,7 +87,7 @@ QString TLDExtractor::TLD(const QString &host) const int labelCount = rule.count(QLatin1Char('.')) + 1; if (rule.startsWith(QLatin1Char('!'))) { - rule = rule.remove(0, 1); + rule.remove(0, 1); rule = QString::fromUtf8(QUrl::toAce(rule)); isExceptionTLD = true; @@ -135,7 +135,7 @@ QString TLDExtractor::TLD(const QString &host) temp = temp.mid(temp.lastIndexOf(QLatin1Char('.')) + 1); - tldPart = temp.isEmpty() ? rule : (temp + "." + rule); + tldPart = temp.isEmpty() ? rule : (temp + QLatin1Char('.') + rule); } } }