A faster method for retrieving a message without getMsg + unGetMsg (*)

It simply combines the code from getMsg and readMsg, without the mMsgList.set() call.

(*) Callgrind shows that unGetMsg takes time too, mostly due to strippedSubjectMD5(),
so let's avoid it altogether, as discussed with Till.

svn path=/branches/KDE_3_3_BRANCH/kdepim/; revision=360560
wilder-work
David Faure 22 years ago
parent eb6879e558
commit 4efae064bc
  1. 29
      folderstorage.cpp
  2. 6
      folderstorage.h

@ -427,12 +427,10 @@ void FolderStorage::take(QPtrList<KMMessage> msgList)
//-----------------------------------------------------------------------------
KMMessage* FolderStorage::getMsg(int idx)
{
KMMsgBase* mb;
if(!(idx >= 0 && idx <= count()))
return 0;
mb = getMsgBase(idx);
KMMsgBase* mb = getMsgBase(idx);
if (!mb) return 0;
#if 0
@ -464,8 +462,33 @@ KMMessage* FolderStorage::getMsg(int idx)
msg->setComplete( true );
return msg;
#endif
}
//-----------------------------------------------------------------------------
KMMessage* FolderStorage::readTemporaryMsg(int idx)
{
if(!(idx >= 0 && idx <= count()))
return 0;
KMMsgBase* mb = getMsgBase(idx);
if (!mb) return 0;
KMMessage *msg = 0;
bool undo = mb->enableUndo();
if (mb->isMessage()) {
// the caller will delete it, so we must make a copy it
msg = new KMMessage(*(KMMessage*)mb);
} else {
// ## Those two lines need to be moved to a virtual method for KMFolderSearch, like readMsg
msg = new KMMessage(*(KMMsgInfo*)mb);
msg->fromDwString(getDwString(idx));
}
msg->setEnableUndo(undo);
if (msg->getMsgSerNum() == 0) {
msg->setMsgSerNum(kmkernel->msgDict()->insert(0, msg, idx));
}
msg->setComplete( true );
return msg;
}

@ -144,6 +144,12 @@ public:
/** Checks if the message is already "gotten" with getMsg */
virtual bool isMessage(int idx);
/** Load message from file and do NOT store it, only return it.
This is equivalent to, but faster than, getMsg+unGetMsg
WARNING: the caller has to delete the returned value!
*/
virtual KMMessage* readTemporaryMsg(int idx);
/** Read a message and return a referece to a string */
virtual QCString& getMsgString(int idx, QCString& mDest) = 0;

Loading…
Cancel
Save