1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-13 10:32:11 +01:00

GIT_SILENT: minor qstring optimization

This commit is contained in:
Laurent Montel 2019-09-13 08:03:02 +02:00
parent f9471ba01a
commit c772438470
17 changed files with 32 additions and 32 deletions

View File

@ -451,7 +451,7 @@ void AdBlockRule::parseFilter()
// Exception always starts with @@ // Exception always starts with @@
if (parsedLine.startsWith(QL1S("@@"))) { if (parsedLine.startsWith(QL1S("@@"))) {
m_isException = true; m_isException = true;
parsedLine = parsedLine.mid(2); parsedLine.remove(0, 2);
} }
// Parse all options following $ char // Parse all options following $ char
@ -550,12 +550,12 @@ void AdBlockRule::parseFilter()
return; return;
} }
parsedLine = parsedLine.left(optionsIndex); parsedLine.truncate(optionsIndex);
} }
// Rule is classic regexp // Rule is classic regexp
if (parsedLine.startsWith(QL1C('/')) && parsedLine.endsWith(QL1C('/'))) { if (parsedLine.startsWith(QL1C('/')) && parsedLine.endsWith(QL1C('/'))) {
parsedLine = parsedLine.mid(1); parsedLine.remove(0, 1);
parsedLine = parsedLine.left(parsedLine.size() - 1); parsedLine = parsedLine.left(parsedLine.size() - 1);
m_type = RegExpMatchRule; m_type = RegExpMatchRule;
@ -570,7 +570,7 @@ void AdBlockRule::parseFilter()
// Remove starting and ending wildcards (*) // Remove starting and ending wildcards (*)
if (parsedLine.startsWith(QL1C('*'))) { if (parsedLine.startsWith(QL1C('*'))) {
parsedLine = parsedLine.mid(1); parsedLine.remove(0, 1);
} }
if (parsedLine.endsWith(QL1C('*'))) { if (parsedLine.endsWith(QL1C('*'))) {
@ -579,7 +579,7 @@ void AdBlockRule::parseFilter()
// We can use fast string matching for domain here // We can use fast string matching for domain here
if (filterIsOnlyDomain(parsedLine)) { if (filterIsOnlyDomain(parsedLine)) {
parsedLine = parsedLine.mid(2); parsedLine.remove(0, 2);
parsedLine = parsedLine.left(parsedLine.size() - 1); parsedLine = parsedLine.left(parsedLine.size() - 1);
m_type = DomainMatchRule; m_type = DomainMatchRule;

View File

@ -98,11 +98,11 @@ bool CookieJar::matchDomain(QString cookieDomain, QString siteDomain) const
// Remove leading dot // Remove leading dot
if (cookieDomain.startsWith(QLatin1Char('.'))) { if (cookieDomain.startsWith(QLatin1Char('.'))) {
cookieDomain = cookieDomain.mid(1); cookieDomain.remove(0, 1);
} }
if (siteDomain.startsWith(QLatin1Char('.'))) { if (siteDomain.startsWith(QLatin1Char('.'))) {
siteDomain = siteDomain.mid(1); siteDomain.remove(0, 1);
} }
return QzTools::matchDomain(cookieDomain, siteDomain); return QzTools::matchDomain(cookieDomain, siteDomain);

View File

@ -222,7 +222,7 @@ QString CookieManager::cookieDomain(const QNetworkCookie &cookie) const
{ {
QString domain = cookie.domain(); QString domain = cookie.domain();
if (domain.startsWith(QLatin1Char('.'))) { if (domain.startsWith(QLatin1Char('.'))) {
domain = domain.mid(1); domain.remove(0, 1);
} }
return domain; return domain;
} }

View File

@ -122,7 +122,7 @@ QString OpenSearchEngine::parseTemplate(const QString &searchTerm, const QString
{ {
QString language = QLocale().name(); QString language = QLocale().name();
// Simple conversion to RFC 3066. // Simple conversion to RFC 3066.
language = language.replace(QLatin1Char('_'), QLatin1Char('-')); language.replace(QLatin1Char('_'), QLatin1Char('-'));
QString result = searchTemplate; QString result = searchTemplate;
result.replace(QLatin1String("{count}"), QLatin1String("20")); result.replace(QLatin1String("{count}"), QLatin1String("20"));
@ -540,7 +540,7 @@ QByteArray OpenSearchEngine::getSuggestionsParameters()
Parameters::const_iterator end = m_suggestionsParameters.constEnd(); Parameters::const_iterator end = m_suggestionsParameters.constEnd();
Parameters::const_iterator i = m_suggestionsParameters.constBegin(); Parameters::const_iterator i = m_suggestionsParameters.constBegin();
for (; i != end; ++i) { for (; i != end; ++i) {
parameters.append(i->first + QLatin1String("=") + i->second); parameters.append(i->first + QLatin1Char('=') + i->second);
} }
QByteArray data = parameters.join(QLatin1String("&")).toUtf8(); 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 end = m_suggestionsParameters.constEnd();
Parameters::const_iterator i = m_suggestionsParameters.constBegin(); Parameters::const_iterator i = m_suggestionsParameters.constBegin();
for (; i != end; ++i) { for (; i != end; ++i) {
parameters.append(i->first + QLatin1String("=") + i->second); parameters.append(i->first + QLatin1Char('=') + i->second);
} }
QByteArray data = parameters.join(QLatin1String("&")).toUtf8(); 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 end = m_searchParameters.constEnd();
Parameters::const_iterator i = m_searchParameters.constBegin(); Parameters::const_iterator i = m_searchParameters.constBegin();
for (; i != end; ++i) { for (; i != end; ++i) {
parameters.append(i->first + QLatin1String("=") + i->second); parameters.append(i->first + QLatin1Char('=') + i->second);
} }
data = parameters.join(QLatin1String("&")).toUtf8(); data = parameters.join(QLatin1String("&")).toUtf8();

View File

@ -190,7 +190,7 @@ void SiteInfo::saveImage()
QString imageFileName = QzTools::getFileNameFromUrl(QUrl(item->text(1))); QString imageFileName = QzTools::getFileNameFromUrl(QUrl(item->text(1)));
int index = imageFileName.lastIndexOf(QLatin1Char('.')); int index = imageFileName.lastIndexOf(QLatin1Char('.'));
if (index != -1) { if (index != -1) {
imageFileName = imageFileName.left(index); imageFileName.truncate(index);
imageFileName.append(QL1S(".png")); imageFileName.append(QL1S(".png"));
} }

View File

@ -61,7 +61,7 @@ SiteInfoWidget::SiteInfoWidget(BrowserWindow* window, QWidget* parent)
if (query.next()) { if (query.next()) {
int count = query.value(0).toInt(); int count = query.value(0).toInt();
if (count > 3) { if (count > 3) {
ui->historyLabel->setText(tr("This is your <b>%1</b> visit of this site.").arg(QString::number(count) + ".")); ui->historyLabel->setText(tr("This is your <b>%1</b> visit of this site.").arg(QString::number(count) + QLatin1Char('.')));
ui->historyIcon->setPixmap(QPixmap(":/icons/locationbar/visit3.png")); ui->historyIcon->setPixmap(QPixmap(":/icons/locationbar/visit3.png"));
} }
else if (count == 0) { else if (count == 0) {

View File

@ -55,7 +55,7 @@ QStringList AcceptLanguage::defaultLanguage()
QByteArray AcceptLanguage::generateHeader(const QStringList &langs) QByteArray AcceptLanguage::generateHeader(const QStringList &langs)
{ {
if (langs.count() == 0) { if (langs.isEmpty()) {
return QByteArray(); return QByteArray();
} }
@ -126,7 +126,7 @@ QStringList AcceptLanguage::expand(const QLocale::Language &language)
languageString = QString(QLatin1String("%1/%2 [%3]")) languageString = QString(QLatin1String("%1/%2 [%3]"))
.arg(QLocale::languageToString(language)) .arg(QLocale::languageToString(language))
.arg(QLocale::countryToString(countries.at(j))) .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)) { if (!allLanguages.contains(languageString)) {

View File

@ -90,7 +90,7 @@ void ButtonWithMenu::removeItem(const Item &item)
m_items.remove(index); m_items.remove(index);
if (m_items.count() == 0) { if (m_items.isEmpty()) {
setIcon(QIcon()); setIcon(QIcon());
return; return;
} }

View File

@ -279,8 +279,8 @@ QString CertificateInfoWidget::clearCertSpecialSymbols(const QString &string)
n.replace(QLatin1String("\\xC2\\xBD"), QLatin1String("1/2")); // one half n.replace(QLatin1String("\\xC2\\xBD"), QLatin1String("1/2")); // one half
n.replace(QLatin1String("\\xC2\\xBE"), QLatin1String("3/4")); // three quarters n.replace(QLatin1String("\\xC2\\xBE"), QLatin1String("3/4")); // three quarters
n.replace(QLatin1String("\\xCA\\xBF"), QLatin1String("\\x27")); // c-single quote n.replace(QLatin1String("\\xCA\\xBF"), QLatin1String("\\x27")); // c-single quote
n.replace(QLatin1String("\\xCC\\xA8"), QString()); // modifier - under curve n.remove(QLatin1String("\\xCC\\xA8")); // modifier - under curve
n.replace(QLatin1String("\\xCC\\xB1"), QString()); // modifier - under line n.remove(QLatin1String("\\xCC\\xB1")); // modifier - under line
return n; return n;
} }

View File

@ -32,7 +32,7 @@ void ClosedTabsManager::saveTab(WebTab *tab)
} }
// Don't save empty tab // Don't save empty tab
if (tab->url().isEmpty() && tab->history()->items().count() == 0) { if (tab->url().isEmpty() && tab->history()->items().isEmpty()) {
return; return;
} }

View File

@ -379,16 +379,16 @@ QString QzTools::fileSizeToString(qint64 size)
double _size = size / 1024.0; // KB double _size = size / 1024.0; // KB
if (_size < 1000) { 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 _size /= 1024; // MB
if (_size < 1000) { 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 _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) 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) { if (!success) {
QString info = "<ul><li><b>%1</b>%2</li><li><b>%3</b>%4</li></ul>"; QString info = "<ul><li><b>%1</b>%2</li><li><b>%3</b>%4</li></ul>";
info = info.arg(QObject::tr("Executable: "), executable, 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"), QMessageBox::critical(0, QObject::tr("Cannot start external program"),
QObject::tr("Cannot start external program! %1").arg(info)); QObject::tr("Cannot start external program! %1").arg(info));

View File

@ -143,7 +143,7 @@ void TreeWidget::filterString(const QString &string)
bool TreeWidget::appendToParentItem(const QString &parentText, QTreeWidgetItem* item) bool TreeWidget::appendToParentItem(const QString &parentText, QTreeWidgetItem* item)
{ {
QList<QTreeWidgetItem*> list = findItems(parentText, Qt::MatchExactly); QList<QTreeWidgetItem*> list = findItems(parentText, Qt::MatchExactly);
if (list.count() == 0) { if (list.isEmpty()) {
return false; return false;
} }
QTreeWidgetItem* parentItem = list.at(0); QTreeWidgetItem* parentItem = list.at(0);
@ -170,7 +170,7 @@ bool TreeWidget::appendToParentItem(QTreeWidgetItem* parent, QTreeWidgetItem* it
bool TreeWidget::prependToParentItem(const QString &parentText, QTreeWidgetItem* item) bool TreeWidget::prependToParentItem(const QString &parentText, QTreeWidgetItem* item)
{ {
QList<QTreeWidgetItem*> list = findItems(parentText, Qt::MatchExactly); QList<QTreeWidgetItem*> list = findItems(parentText, Qt::MatchExactly);
if (list.count() == 0) { if (list.isEmpty()) {
return false; return false;
} }
QTreeWidgetItem* parentItem = list.at(0); QTreeWidgetItem* parentItem = list.at(0);

View File

@ -215,7 +215,7 @@ void FCM_Dialog::refreshFlashCookiesTree()
QString cookieOrigin = flashCookie.origin; QString cookieOrigin = flashCookie.origin;
if (cookieOrigin.startsWith(QLatin1Char('.'))) { if (cookieOrigin.startsWith(QLatin1Char('.'))) {
cookieOrigin = cookieOrigin.mid(1); cookieOrigin.remove(0, 1);
} }
QTreeWidgetItem* findParent = hash.value(cookieOrigin); QTreeWidgetItem* findParent = hash.value(cookieOrigin);

View File

@ -449,7 +449,7 @@ QString FCM_Plugin::extractOriginFrom(const QString &path)
if (index == -1) { if (index == -1) {
return tr("!other"); return tr("!other");
} }
origin = origin.remove(index, origin.size()); origin.remove(index, origin.size());
if (origin == QL1S("localhost") || origin == QL1S("local")) { if (origin == QL1S("localhost") || origin == QL1S("local")) {
origin = QL1S("!localhost"); origin = QL1S("!localhost");
} }

View File

@ -115,7 +115,7 @@ void PIM_Handler::populateWebViewMenu(QMenu* menu, WebView* view, const WebHitTe
pimMenu->setIcon(QIcon(":/PIM/data/PIM.png")); pimMenu->setIcon(QIcon(":/PIM/data/PIM.png"));
if (!m_allInfo[PI_FirstName].isEmpty() && !m_allInfo[PI_LastName].isEmpty()) { 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); QAction* action = pimMenu->addAction(fullname, this, &PIM_Handler::pimInsert);
action->setData(fullname); action->setData(fullname);
} }

View File

@ -77,7 +77,7 @@ void SBI_NetworkIcon::showMenu(const QPoint &pos)
act->setChecked(it.value() == SBINetManager->currentProxy()); act->setChecked(it.value() == SBINetManager->currentProxy());
} }
if (proxyMenu->actions().count() == 0) { if (proxyMenu->actions().isEmpty()) {
proxyMenu->addAction(tr("Empty"))->setEnabled(false); proxyMenu->addAction(tr("Empty"))->setEnabled(false);
} }

View File

@ -87,7 +87,7 @@ QString TLDExtractor::TLD(const QString &host)
const int labelCount = rule.count(QLatin1Char('.')) + 1; const int labelCount = rule.count(QLatin1Char('.')) + 1;
if (rule.startsWith(QLatin1Char('!'))) { if (rule.startsWith(QLatin1Char('!'))) {
rule = rule.remove(0, 1); rule.remove(0, 1);
rule = QString::fromUtf8(QUrl::toAce(rule)); rule = QString::fromUtf8(QUrl::toAce(rule));
isExceptionTLD = true; isExceptionTLD = true;
@ -135,7 +135,7 @@ QString TLDExtractor::TLD(const QString &host)
temp = temp.mid(temp.lastIndexOf(QLatin1Char('.')) + 1); temp = temp.mid(temp.lastIndexOf(QLatin1Char('.')) + 1);
tldPart = temp.isEmpty() ? rule : (temp + "." + rule); tldPart = temp.isEmpty() ? rule : (temp + QLatin1Char('.') + rule);
} }
} }
} }