# HG changeset patch # User Adrian Buehlmann # Date 2012-09-16 09:41:02 # Node ID 9a5c2ecd1158881b3e015e5d23e3ff36cfe47b48 # Parent eb0884680f5c002a7320b696b8069edd6fc3acb2 store: move encode lambda logic into fncachestore and define two named functions at module scope. This again also speeds up perffncacheencode a little bit. diff --git a/mercurial/store.py b/mercurial/store.py --- a/mercurial/store.py +++ b/mercurial/store.py @@ -396,8 +396,18 @@ class _fncacheopener(scmutil.abstractope 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 @@ class fncachestore(basicstore): 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)