Implement more efficient functions for the MappedUID case
We are calling getmessagelist() internally a lot, e.g. just to check if a UID exists (from uidexist()). This is a very expensive operation in the UIDMapped case, as we reconstruct the whole messagelist dict every single time, involving lots of copying etc. So we provide more efficient implementations for the uidexists() getmessageuidlist() and getmessagecount() functions that are fast in the UIDMapped case. This should solve the performance regression that was recently observed in the Mapped UID case. 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:
parent
0f85e592a3
commit
ca012d3a81
@ -107,9 +107,30 @@ class MappingFolderMixIn:
|
|||||||
finally:
|
finally:
|
||||||
self.maplock.release()
|
self.maplock.release()
|
||||||
|
|
||||||
|
def uidexists(self, ruid):
|
||||||
|
"""Checks if the (remote) UID exists in this Folder"""
|
||||||
|
# This implementation overrides the one in BaseFolder, as it is
|
||||||
|
# much more efficient for the mapped case.
|
||||||
|
return ruid in self.r2l
|
||||||
|
|
||||||
|
def getmessageuidlist(self):
|
||||||
|
"""Gets a list of (remote) UIDs.
|
||||||
|
You may have to call cachemessagelist() before calling this function!"""
|
||||||
|
# This implementation overrides the one in BaseFolder, as it is
|
||||||
|
# much more efficient for the mapped case.
|
||||||
|
return self.r2l.keys()
|
||||||
|
|
||||||
|
def getmessagecount(self):
|
||||||
|
"""Gets the number of messages in this folder.
|
||||||
|
You may have to call cachemessagelist() before calling this function!"""
|
||||||
|
# This implementation overrides the one in BaseFolder, as it is
|
||||||
|
# much more efficient for the mapped case.
|
||||||
|
return len(self.r2l)
|
||||||
|
|
||||||
def getmessagelist(self):
|
def getmessagelist(self):
|
||||||
"""Gets the current message list.
|
"""Gets the current message list. This function's implementation
|
||||||
You must call cachemessagelist() before calling this function!"""
|
is quite expensive for the mapped UID case. You must call
|
||||||
|
cachemessagelist() before calling this function!"""
|
||||||
|
|
||||||
retval = {}
|
retval = {}
|
||||||
localhash = self._mb.getmessagelist(self)
|
localhash = self._mb.getmessagelist(self)
|
||||||
|
Loading…
Reference in New Issue
Block a user