[PATCH 1/3] folder/Maildir: cache getfullname() value
Sebastian Spaeth
Sebastian at SSpaeth.de
Fri Jun 10 16:32:39 BST 2011
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 at SSpaeth.de>
---
offlineimap/folder/Maildir.py | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/offlineimap/folder/Maildir.py b/offlineimap/folder/Maildir.py
index e360619..b9f9d05 100644
--- a/offlineimap/folder/Maildir.py
+++ b/offlineimap/folder/Maildir.py
@@ -63,12 +63,15 @@ class MaildirFolder(BaseFolder):
self.accountname = accountname
BaseFolder.__init__(self)
#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):
return self.accountname
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):
"""Maildirs have no notion of uidvalidity, so we just return a magic
--
1.7.4.1
More information about the OfflineIMAP-project
mailing list