Rev 1760: Cache properties in memory. in file:///data/jelmer/bzr-svn/trunk/

Jelmer Vernooij jelmer at samba.org
Mon Sep 1 20:37:00 BST 2008


At file:///data/jelmer/bzr-svn/trunk/

------------------------------------------------------------
revno: 1760
revision-id: jelmer at samba.org-20080901193656-u3lekmn9jnw932v5
parent: jelmer at samba.org-20080901185805-6gxszly5r1262sbt
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Mon 2008-09-01 21:36:56 +0200
message:
  Cache properties in memory.
modified:
  branchprops.py                 branchprops.py-20061223204623-80lvm7pjrpsgk0dd-1
=== modified file 'branchprops.py'
--- a/branchprops.py	2008-08-25 01:58:11 +0000
+++ b/branchprops.py	2008-09-01 19:36:56 +0000
@@ -26,6 +26,7 @@
 class PathPropertyProvider(object):
     def __init__(self, log):
         self.log = log
+        self._props_cache = {}
 
     def get_properties(self, path, revnum):
         """Obtain all the directory properties set on a path/revnum pair.
@@ -37,6 +38,9 @@
         assert isinstance(path, str)
         path = path.lstrip("/")
 
+        if (path, revnum) in self._props_cache:
+            return self._props_cache[path, revnum]
+
         try:
             (_, _, props) = self.log._transport.get_dir(path, 
                 revnum)
@@ -45,6 +49,7 @@
                 raise NoSuchRevision(self, revnum)
             raise
 
+        self._props_cache[path, revnum] = props
         return props
 
     def get_changed_properties(self, path, revnum):




More information about the bazaar-commits mailing list