IMAP4Protocol::listDir()
André Wöbbeking <[email protected]> Wed, 9 Feb 2005 00:18:30 +0100
| Newsgroups | gmane.comp.kde.devel.optimize,gmane.comp.kde.devel.pim |
|---|---|
| Message-ID | <[email protected]> |
Hi, for IMAP folders with many mails more than 30% is spent in KURL::url() as it's called for every mail in the folder although the url doesn't change. I reduced the number of url() calls by calling it outside the loops (i.e. from 18000 to 100 calls). Another small change is in doListEntry() where QString::number() was called twice for the same number. Can I commit this patch? Cheers, André _______________________________________________ Kde-optimize mailing list [email protected] https://mail.kde.org/mailman/listinfo/kde-optimize
imap4.diff
(text/x-diff, 3.2 KB)
cvs diff: Diffing .
Index: imap4.cc
===================================================================
RCS file: /home/kde/kdepim/kioslaves/imap4/imap4.cc,v
retrieving revision 1.201
diff -u -3 -p -r1.201 imap4.cc
--- imap4.cc 13 Jan 2005 23:55:13 -0000 1.201
+++ imap4.cc 8 Feb 2005 23:04:23 -0000
@@ -497,6 +497,10 @@ IMAP4Protocol::listDir (const KURL & _ur
if ((myType == ITYPE_BOX || myType == ITYPE_DIR_AND_BOX)
&& myLType != "LIST" && myLType != "LSUB" && myLType != "LSUBNOCHECK")
{
+ KURL aURL = _url;
+ aURL.setQuery (QString::null);
+ const QString encodedUrl = aURL.url(0, 106); // utf-8
+
if (!_url.query ().isEmpty ())
{
QString query = KURL::decode_string (_url.query ());
@@ -530,7 +534,7 @@ IMAP4Protocol::listDir (const KURL & _ur
++it)
{
fake.setUid((*it).toULong());
- doListEntry (_url, stretch, &fake);
+ doListEntry (encodedUrl, stretch, &fake);
}
entry.clear ();
listEntry (entry, true);
@@ -599,7 +603,7 @@ IMAP4Protocol::listDir (const KURL & _ur
cache = getLastHandled ();
if (cache && !fetch->isComplete())
- doListEntry (_url, stretch, cache, withFlags, withSubject);
+ doListEntry (encodedUrl, stretch, cache, withFlags, withSubject);
}
while (!fetch->isComplete ());
entry.clear ();
@@ -2010,17 +2014,29 @@ void
IMAP4Protocol::doListEntry (const KURL & _url, int stretch, imapCache * cache,
bool withFlags, bool withSubject)
{
+ KURL aURL = _url;
+ aURL.setQuery (QString::null);
+ const QString encodedUrl = aURL.url(0, 106); // utf-8
+ doListEntry(encodedUrl, stretch, cache, withFlags, withSubject);
+}
+
+
+
+void
+IMAP4Protocol::doListEntry (const QString & encodedUrl, int stretch, imapCache * cache,
+ bool withFlags, bool withSubject)
+{
if (cache)
{
UDSEntry entry;
UDSAtom atom;
- KURL aURL = _url;
- aURL.setQuery (QString::null);
entry.clear ();
+ const QString uid = QString::number(cache->getUid());
+
atom.m_uds = UDS_NAME;
- atom.m_str = QString::number(cache->getUid());
+ atom.m_str = uid;
atom.m_long = 0;
if (stretch > 0)
{
@@ -2036,10 +2052,10 @@ IMAP4Protocol::doListEntry (const KURL &
entry.append (atom);
atom.m_uds = UDS_URL;
- atom.m_str = aURL.url(0, 106); // utf-8
+ atom.m_str = encodedUrl; // utf-8
if (atom.m_str[atom.m_str.length () - 1] != '/')
atom.m_str += '/';
- atom.m_str += ";UID=" + QString::number(cache->getUid());
+ atom.m_str += ";UID=" + uid;
atom.m_long = 0;
entry.append (atom);
Index: imap4.h
===================================================================
RCS file: /home/kde/kdepim/kioslaves/imap4/imap4.h,v
retrieving revision 1.50
diff -u -3 -p -r1.50 imap4.h
--- imap4.h 10 Jan 2005 12:27:29 -0000 1.50
+++ imap4.h 8 Feb 2005 23:04:23 -0000
@@ -171,6 +171,9 @@ protected:
private:
+ void doListEntry (const QString & encodedUrl, int stretch, imapCache * cache = NULL,
+ bool withFlags = FALSE, bool withSubject = FALSE);
+
QString myHost, myUser, myPass, myAuth, myTLS;
int myPort;
bool mySSL;