From c1c200a487cc36381d17275f2f439665c3f11cb0 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Fri, 10 Jun 2011 17:32:39 +0200 Subject: [PATCH] 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 Signed-off-by: Nicolas Sebrecht --- offlineimap/folder/Maildir.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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