changeset 17591:9a5c2ecd1158

store: move encode lambda logic into fncachestore and define two named functions at module scope. This again also speeds up perffncacheencode a little bit.
author Adrian Buehlmann <adrian@cadifra.com>
date Sun, 16 Sep 2012 11:41:02 +0200
parents eb0884680f5c
children 64c6a0d4d4bd
files mercurial/store.py
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/store.py	Sun Sep 16 11:36:14 2012 +0200
+++ b/mercurial/store.py	Sun Sep 16 11:41:02 2012 +0200
@@ -396,8 +396,18 @@
             self.fncache.add(path)
         return self.opener(self.encode(path), mode, *args, **kw)
 
+def _plainhybridencode(f):
+    return _hybridencode(f, False)
+
+def _dothybridencode(f):
+    return _hybridencode(f, True)
+
 class fncachestore(basicstore):
-    def __init__(self, path, openertype, encode):
+    def __init__(self, path, openertype, dotencode):
+        if dotencode:
+            encode = _dothybridencode
+        else:
+            encode = _plainhybridencode
         self.encode = encode
         self.path = path + '/store'
         self.pathsep = self.path + '/'
@@ -444,8 +454,6 @@
 def store(requirements, path, openertype):
     if 'store' in requirements:
         if 'fncache' in requirements:
-            de = 'dotencode' in requirements
-            encode = lambda f: _hybridencode(f, de)
-            return fncachestore(path, openertype, encode)
+            return fncachestore(path, openertype, 'dotencode' in requirements)
         return encodedstore(path, openertype)
     return basicstore(path, openertype)