Replace calls to getmessagelist() to alternatives

getmessagelist() is slow for the mapped UID case, so replace some of its
occurences with calls that are optimized for this case, ie
getmessagecount() and uidexists().

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Reviewed-and-tested-by: Vincent Beffara <vbeffara@ens-lyon.fr>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Sebastian Spaeth 2011-03-28 10:19:20 -04:00 committed by Nicolas Sebrecht
parent ca012d3a81
commit 58220fd8e7
2 changed files with 4 additions and 4 deletions

View File

@ -318,7 +318,7 @@ class BaseFolder:
flags = self.getmessageflags(uid) flags = self.getmessageflags(uid)
rtime = self.getmessagetime(uid) rtime = self.getmessagetime(uid)
if uid in dstfolder.getmessagelist(): if dstfolder.uidexists(uid):
# dst has message with that UID already, only update status # dst has message with that UID already, only update status
statusfolder.savemessage(uid, None, flags, rtime) statusfolder.savemessage(uid, None, flags, rtime)
return return

View File

@ -94,7 +94,7 @@ class IMAPFolder(BaseFolder):
maxmsgid = max(long(msgid), maxmsgid) maxmsgid = max(long(msgid), maxmsgid)
# Different number of messages than last time? # Different number of messages than last time?
if maxmsgid != len(statusfolder.getmessagelist()): if maxmsgid != statusfolder.getmessagecount():
return True return True
if maxmsgid < 1: if maxmsgid < 1:
@ -112,7 +112,7 @@ class IMAPFolder(BaseFolder):
if not options.has_key('UID'): if not options.has_key('UID'):
return True return True
uid = long(options['UID']) uid = long(options['UID'])
saveduids = statusfolder.getmessagelist().keys() saveduids = statusfolder.getmessageuidlist()
saveduids.sort() saveduids.sort()
if uid != saveduids[-1]: if uid != saveduids[-1]:
return True return True
@ -395,7 +395,7 @@ class IMAPFolder(BaseFolder):
self.ui.debug('imap', 'savemessage: called') self.ui.debug('imap', 'savemessage: called')
# already have it, just save modified flags # already have it, just save modified flags
if uid > 0 and uid in self.messagelist: if uid > 0 and self.uidexists(uid):
self.savemessageflags(uid, flags) self.savemessageflags(uid, flags)
return uid return uid