localrepo: use propertycaches to access encode/decode filters
authorNicolas Dumazet <nicdumz.commits@gmail.com>
Sun, 10 Oct 2010 18:58:45 +0200
changeset 12708 8a08b12ae88e
parent 12707 2216ab103ea8
child 12709 4147a292c508
localrepo: use propertycaches to access encode/decode filters
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Sun Oct 10 19:10:16 2010 +0200
+++ b/mercurial/localrepo.py	Sun Oct 10 18:58:45 2010 +0200
@@ -597,6 +597,14 @@
 
         return data
 
+    @propertycache
+    def _encodefilterpats(self):
+        return self._loadfilter('encode')
+
+    @propertycache
+    def _decodefilterpats(self):
+        return self._loadfilter('decode')
+
     def adddatafilter(self, name, filter):
         self._datafilters[name] = filter
 
@@ -605,10 +613,10 @@
             data = os.readlink(self.wjoin(filename))
         else:
             data = self.wopener(filename, 'r').read()
-        return self._filter(self._loadfilter("encode"), filename, data)
+        return self._filter(self._encodefilterpats, filename, data)
 
     def wwrite(self, filename, data, flags):
-        data = self._filter(self._loadfilter("decode"), filename, data)
+        data = self._filter(self._decodefilterpats, filename, data)
         try:
             os.unlink(self.wjoin(filename))
         except OSError:
@@ -621,7 +629,7 @@
                 util.set_flags(self.wjoin(filename), False, True)
 
     def wwritedata(self, filename, data):
-        return self._filter(self._loadfilter("decode"), filename, data)
+        return self._filter(self._decodefilterpats, filename, data)
 
     def transaction(self, desc):
         tr = self._transref and self._transref() or None