Commit d858a9f8 authored by Laurent Montel's avatar Laurent Montel 😁

Minor optimization

parent 67b90da6
......@@ -46,7 +46,7 @@ Capabilities Capabilities::fromResponse(const Response &ehlo)
QCStringList l = ehlo.lines();
for (QCStringList::const_iterator it = ++l.constBegin(); it != l.constEnd(); ++it) {
for (QCStringList::const_iterator it = ++l.constBegin(), end(l.constEnd()); it != end; ++it) {
c.add(QString::fromLatin1(*it));
}
......@@ -106,8 +106,8 @@ QString Capabilities::createSpecialResponse(bool tls) const
QStringList Capabilities::saslMethodsQSL() const
{
QStringList result;
for (QMap<QString, QStringList>::const_iterator it = mCapabilities.begin();
it != mCapabilities.end(); ++it) {
for (QMap<QString, QStringList>::const_iterator it = mCapabilities.begin(), end(mCapabilities.end());
it != end; ++it) {
if (it.key() == QLatin1String("AUTH")) {
result += it.value();
} else if (it.key().startsWith(QLatin1String("AUTH="))) {
......
......@@ -174,7 +174,7 @@ QByteArray StartTLSCommand::nextCommandLine(TransactionState *ts)
Q_UNUSED(ts)
mComplete = true;
mNeedResponse = true;
return "STARTTLS\r\n";
return QByteArrayLiteral("STARTTLS\r\n");
}
bool StartTLSCommand::processResponse(const Response &r, TransactionState *ts)
......@@ -266,7 +266,7 @@ bool AuthCommand::saslInteract(void *in)
//some mechanisms do not require username && pass, so don't need a popup
//window for getting this info
for (; interact->id != SASL_CB_LIST_END; interact++) {
for (; interact->id != SASL_CB_LIST_END; ++interact) {
if (interact->id == SASL_CB_AUTHNAME
|| interact->id == SASL_CB_PASS) {
if (mAi->username.isEmpty() || mAi->password.isEmpty()) {
......@@ -371,7 +371,7 @@ QByteArray AuthCommand::nextCommandLine(TransactionState *ts)
// qCDebug(SMTP_LOG) << "CC: '" << cmd << "'";
mComplete = (result == SASL_OK);
}
cmd += "\r\n";
cmd += QByteArrayLiteral("\r\n");
return cmd;
}
......@@ -414,14 +414,14 @@ QByteArray MailFromCommand::nextCommandLine(TransactionState *ts)
Q_UNUSED(ts)
mComplete = true;
mNeedResponse = true;
QByteArray cmdLine = "MAIL FROM:<" + mAddr + '>';
QByteArray cmdLine = QByteArrayLiteral("MAIL FROM:<") + mAddr + '>';
if (m8Bit && haveCapability("8BITMIME")) {
cmdLine += " BODY=8BITMIME";
cmdLine += QByteArrayLiteral(" BODY=8BITMIME");
}
if (mSize && haveCapability("SIZE")) {
cmdLine += " SIZE=" + QByteArray().setNum(mSize);
cmdLine += QByteArrayLiteral(" SIZE=") + QByteArray().setNum(mSize);
}
return cmdLine + "\r\n";
return cmdLine + QByteArrayLiteral("\r\n");
}
bool MailFromCommand::processResponse(const Response &r, TransactionState *ts)
......@@ -446,7 +446,7 @@ QByteArray RcptToCommand::nextCommandLine(TransactionState *ts)
Q_UNUSED(ts)
mComplete = true;
mNeedResponse = true;
return "RCPT TO:<" + mAddr + ">\r\n";
return QByteArrayLiteral("RCPT TO:<") + mAddr + QByteArrayLiteral(">\r\n");
}
bool RcptToCommand::processResponse(const Response &r, TransactionState *ts)
......@@ -473,7 +473,7 @@ QByteArray DataCommand::nextCommandLine(TransactionState *ts)
mComplete = true;
mNeedResponse = true;
ts->setDataCommandIssued(true);
return "DATA\r\n";
return QByteArrayLiteral("DATA\r\n");
}
void DataCommand::ungetCommandLine(const QByteArray &cmd, TransactionState *ts)
......@@ -526,8 +526,8 @@ QByteArray TransferCommand::nextCommandLine(TransactionState *ts)
assert(!isComplete());
assert(!ts->failed());
static const QByteArray dotCRLF = ".\r\n";
static const QByteArray CRLFdotCRLF = "\r\n.\r\n";
static const QByteArray dotCRLF = QByteArrayLiteral(".\r\n");
static const QByteArray CRLFdotCRLF = QByteArrayLiteral("\r\n.\r\n");
if (!mUngetBuffer.isEmpty()) {
const QByteArray ret = mUngetBuffer;
......@@ -619,7 +619,7 @@ QByteArray NoopCommand::nextCommandLine(TransactionState *ts)
Q_UNUSED(ts)
mComplete = true;
mNeedResponse = true;
return "NOOP\r\n";
return QByteArrayLiteral("NOOP\r\n");
}
//
......@@ -631,7 +631,7 @@ QByteArray RsetCommand::nextCommandLine(TransactionState *ts)
Q_UNUSED(ts)
mComplete = true;
mNeedResponse = true;
return "RSET\r\n";
return QByteArrayLiteral("RSET\r\n");
}
//
......@@ -643,6 +643,6 @@ QByteArray QuitCommand::nextCommandLine(TransactionState *ts)
Q_UNUSED(ts)
mComplete = true;
mNeedResponse = true;
return "QUIT\r\n";
return QByteArrayLiteral("QUIT\r\n");
}
} // namespace KioSMTP
......@@ -47,7 +47,7 @@ Request Request::fromURL(const QUrl &url)
#ifndef NDEBUG
qCDebug(SMTP_LOG) << "Parsing request from query:\n" << query.join(QLatin1Char('\n'));
#endif
for (QStringList::const_iterator it = query.begin(); it != query.end(); ++it) {
for (QStringList::const_iterator it = query.begin(), end(query.end()); it != end; ++it) {
int equalsPos = (*it).indexOf(QLatin1Char('='));
if (equalsPos <= 0) {
continue;
......@@ -177,10 +177,10 @@ QByteArray Request::headerFields(const QString &fromRealName) const
assert(hasFromAddress()); // should have been checked for by
// caller (MAIL FROM comes before DATA)
QByteArray result = "From: " + formatFromAddress(fromRealName, fromAddress()) + "\r\n";
QByteArray result = QByteArrayLiteral("From: ") + formatFromAddress(fromRealName, fromAddress()) + QByteArrayLiteral("\r\n");
if (!subject().isEmpty()) {
result += "Subject: " + formatSubject(subject()) + "\r\n";
result += QByteArrayLiteral("Subject: ") + formatSubject(subject()) + QByteArrayLiteral("\r\n");
}
if (!to().empty()) {
result += QByteArrayLiteral("To: ") + to().join(QStringLiteral(",\r\n\t") /* line folding */).toLatin1() + "\r\n";
......
......@@ -97,7 +97,7 @@ static QByteArray join(char sep, const QCStringList &list)
return QByteArray();
}
QByteArray result = list.front();
for (QCStringList::const_iterator it = ++list.begin(); it != list.end(); ++it) {
for (QCStringList::const_iterator it = ++list.begin(), end(list.end()); it != end; ++it) {
result += sep + *it;
}
return result;
......
......@@ -235,7 +235,7 @@ void SMTPProtocol::put(const QUrl &url, int permissions, KIO::JobFlags flags)
// Loop through our To and CC recipients, and send the proper
// SMTP commands, for the benefit of the server.
const QStringList recipients = request.recipients();
for (QStringList::const_iterator it = recipients.begin(); it != recipients.end(); ++it) {
for (QStringList::const_iterator it = recipients.begin(), end(recipients.end()); it != end; ++it) {
queueCommand(new RcptToCommand(m_sessionIface, (*it).toLatin1()));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment