From b3a21311f816a6f5ac91c1d7b94868e42ad42c1c Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 12 May 2011 08:41:25 -0400 Subject: [PATCH] Cache Bug.time by hand to avoid lots of redundant calls to str_to_time. --- libbe/bug.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libbe/bug.py b/libbe/bug.py index 8b4b130..47e4b67 100644 --- a/libbe/bug.py +++ b/libbe/bug.py @@ -194,10 +194,19 @@ class Bug (settings_object.SavedSettingsObject): def _get_time(self): if self.time_string == None: + self._cached_time_string = None + self._cached_time = None return None - return utility.str_to_time(self.time_string) + if (not hasattr(self, '_cached_time_string') + or self.time_string != self._cached_time_string): + self._cached_time_string = self.time_string + self._cached_time = utility.str_to_time(self.time_string) + return self._cached_time def _set_time(self, value): - self.time_string = utility.time_to_str(value) + if not hasattr(self, '_cached_time') or value != self._cached_time: + self.time_string = utility.time_to_str(value) + self._cached_time_string = self.time_string + self._cached_time = value time = property(fget=_get_time, fset=_set_time, doc="An integer version of .time_string") -- 2.26.2