aboutsummaryrefslogtreecommitdiffstats
path: root/libbe
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-07-27 05:57:40 -0400
committerW. Trevor King <wking@drexel.edu>2009-07-27 05:57:40 -0400
commit5ce4bd3f4ce955577c46fe8e3c5a8f54b60ce3df (patch)
tree9cc5d2051cfc5c4f69aa659efcfc19a0d6d5e2f4 /libbe
parente21a427afbc7369cfa3a3f786e51aaa1e3e01999 (diff)
downloadbugseverywhere-5ce4bd3f4ce955577c46fe8e3c5a8f54b60ce3df.tar.gz
Cache data strings in libbe.diff.DiffTree.
This makes repeated .report() generation from the same tree more efficient.
Diffstat (limited to 'libbe')
-rw-r--r--libbe/diff.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/libbe/diff.py b/libbe/diff.py
index 59e7c66..decbcf5 100644
--- a/libbe/diff.py
+++ b/libbe/diff.py
@@ -120,12 +120,15 @@ class DiffTree (tree.Tree):
if part != None:
root.append(part)
def data_string(self, depth, indent=True):
+ if hasattr(self, "_cached_data_string"):
+ return self._cached_data_string
data_string = self.data_string_fn(self.data)
if indent == True:
data_string_lines = data_string.splitlines()
indent = " "*(depth)
line_sep = "\n"+indent
data_string = indent+line_sep.join(data_string_lines)
+ self._cached_data_string = data_string
return data_string
class Diff (object):