mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
GIT_SILENT: minor qstring optimization
This commit is contained in:
parent
f9471ba01a
commit
c772438470
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
|
||||
|
|
|
@ -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 <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"));
|
||||
}
|
||||
else if (count == 0) {
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 = "<ul><li><b>%1</b>%2</li><li><b>%3</b>%4</li></ul>";
|
||||
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));
|
||||
|
|
|
@ -143,7 +143,7 @@ void TreeWidget::filterString(const QString &string)
|
|||
bool TreeWidget::appendToParentItem(const QString &parentText, QTreeWidgetItem* item)
|
||||
{
|
||||
QList<QTreeWidgetItem*> 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<QTreeWidgetItem*> list = findItems(parentText, Qt::MatchExactly);
|
||||
if (list.count() == 0) {
|
||||
if (list.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
QTreeWidgetItem* parentItem = list.at(0);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user