summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-26 04:45:50 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-26 04:45:50 (GMT)
commit0228ac5a9ceb93419d62cf42cd70d5c45ed2d314 (patch)
tree37d90e2b2ffea41d069c9cd748b6e62bdad39584
parent984cfcac26054c91e2a5418d0be95ff8ac0c77dc (diff)
Minor optimization
-rw-r--r--src/filter/filteractions/filteraction.cpp5
-rw-r--r--src/filter/filteractions/filteractionsetidentity.cpp5
-rw-r--r--src/filter/filteractions/filteractionwithcommand.cpp10
-rw-r--r--src/search/searchrule/searchrulestring.cpp14
4 files changed, 24 insertions, 10 deletions
diff --git a/src/filter/filteractions/filteraction.cpp b/src/filter/filteractions/filteraction.cpp
index afb3f47..9188cb1 100644
--- a/src/filter/filteractions/filteraction.cpp
+++ b/src/filter/filteractions/filteraction.cpp
@@ -115,7 +115,10 @@ void FilterAction::sendMDN(const Akonadi::Item &item, KMime::MDN::DispositionTyp
const QPair<bool, KMime::MDN::SendingMode> mdnSend = MDNAdviceHelper::instance()->checkAndSetMDNInfo(item, type, true);
if (mdnSend.first) {
const int quote = MessageViewer::MessageViewerSettings::self()->quoteMessage();
- QString receiptTo = msg->headerByType("Disposition-Notification-To") ? msg->headerByType("Disposition-Notification-To")->asUnicodeString() : QString();
+ QString receiptTo;
+ if (auto hrd = msg->headerByType("Disposition-Notification-To")) {
+ receiptTo = hrd->asUnicodeString();
+ }
if (receiptTo.isEmpty()) {
return;
}
diff --git a/src/filter/filteractions/filteractionsetidentity.cpp b/src/filter/filteractions/filteractionsetidentity.cpp
index a8453b0..49550d8 100644
--- a/src/filter/filteractions/filteractionsetidentity.cpp
+++ b/src/filter/filteractions/filteractionsetidentity.cpp
@@ -70,7 +70,10 @@ FilterAction::ReturnCode FilterActionSetIdentity::process(ItemContext &context,
}
const KMime::Message::Ptr msg = context.item().payload<KMime::Message::Ptr>();
- const uint currentId = msg->headerByType("X-KMail-Identity") ? msg->headerByType("X-KMail-Identity")->asUnicodeString().trimmed().toUInt() : 0;
+ uint currentId = 0;
+ if (auto hrd = msg->headerByType("X-KMail-Identity")) {
+ currentId = hrd->asUnicodeString().trimmed().toUInt();
+ }
if (currentId != mParameter) {
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-KMail-Identity");
header->fromUnicodeString(QString::number(mParameter), "utf-8");
diff --git a/src/filter/filteractions/filteractionwithcommand.cpp b/src/filter/filteractions/filteractionwithcommand.cpp
index 3b24397..a9b561d 100644
--- a/src/filter/filteractions/filteractionwithcommand.cpp
+++ b/src/filter/filteractions/filteractionwithcommand.cpp
@@ -250,12 +250,18 @@ FilterAction::ReturnCode FilterActionWithCommand::genericProcess(ItemContext &co
unfortunate, as we need to removed the original from the folder
using that, and look it up in the message. When the (new) message
is uploaded, the header is stripped anyhow. */
- const QString uid = aMsg->headerByType("X-UID") ? aMsg->headerByType("X-UID")->asUnicodeString() : QString();
+ QString uid;
+ if (auto hrd = aMsg->headerByType("X-UID")) {
+ uid = hrd->asUnicodeString();
+ }
aMsg->setContent(KMime::CRLFtoLF(msgText));
aMsg->setFrozen(true);
aMsg->parse();
- const QString newUid = aMsg->headerByType("X-UID") ? aMsg->headerByType("X-UID")->asUnicodeString() : QString();
+ QString newUid;
+ if (auto hrd = aMsg->headerByType("X-UID")) {
+ newUid = hrd->asUnicodeString();
+ }
if (uid != newUid) {
aMsg->setFrozen(false);
KMime::Headers::Generic *header = new KMime::Headers::Generic("X-UID");
diff --git a/src/search/searchrule/searchrulestring.cpp b/src/search/searchrule/searchrulestring.cpp
index e053c5e..09615f8 100644
--- a/src/search/searchrule/searchrulestring.cpp
+++ b/src/search/searchrule/searchrulestring.cpp
@@ -151,17 +151,19 @@ bool SearchRuleString::matches(const Akonadi::Item &item) const
} else {
// make sure to treat messages with multiple header lines for
// the same header correctly
- msgContents = msg->headerByType(field()) ?
- msg->headerByType(field())->asUnicodeString() :
- "";
+ msgContents = "";
+ if (auto hrd = msg->headerByType(field())) {
+ msgContents = hrd->asUnicodeString();
+ }
}
if (function() == FuncIsInAddressbook ||
function() == FuncIsNotInAddressbook) {
// I think only the "from"-field makes sense.
- msgContents = msg->headerByType(field()) ?
- msg->headerByType(field())->asUnicodeString() :
- "";
+ msgContents = "";
+ if (auto hrd = msg->headerByType(field())) {
+ msgContents = hrd->asUnicodeString();
+ }
if (msgContents.isEmpty()) {
return (function() == FuncIsInAddressbook) ? false : true;