folder/Maildir: cache getfullname() value

We use getfullname() very often (thousands to millions), yet we
dynamically calculate the very same value over and over. Optimize this
by caching the value once and be done with it.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Sebastian Spaeth 2011-06-10 17:32:39 +02:00 committed by Nicolas Sebrecht
parent 4c8abb0bc6
commit c1c200a487

View File

@ -63,12 +63,15 @@ class MaildirFolder(BaseFolder):
self.accountname = accountname self.accountname = accountname
BaseFolder.__init__(self) BaseFolder.__init__(self)
#self.ui is set in BaseFolder.init() #self.ui is set in BaseFolder.init()
# Cache the full folder path, as we use getfullname() very often
self._fullname = os.path.join(self.getroot(), self.getname())
def getaccountname(self): def getaccountname(self):
return self.accountname return self.accountname
def getfullname(self): def getfullname(self):
return os.path.join(self.getroot(), self.getname()) """Return the absolute file path to the Maildir folder (sans cur|new)"""
return self._fullname
def getuidvalidity(self): def getuidvalidity(self):
"""Maildirs have no notion of uidvalidity, so we just return a magic """Maildirs have no notion of uidvalidity, so we just return a magic