##// END OF EJS Templates
Take advantage of fstat calls clustering per directory if OS support it....
Take advantage of fstat calls clustering per directory if OS support it. util module implements two versions of statfiles function _statfiles calls lstat per file _statfiles_clustered takes advantage of optimizations in osutil.c, stats all files in directory at once when new directory is hit and caches the results util.statfiles dispatches to appropriate version during module loading The speedup on directory tree with 2k directories and 63k files is about factor of 1.8 (1.3s -> 0.8s for hg diff - hg startup overhead about .2s) At this point only Win32 now benefit from this patch. Rest of OSes use the non clustered implementation.

File last commit:

r6834:cbdfd08e default
r7118:619ebf82 default
Show More
match.py
47 lines | 1.4 KiB | text/x-python | PythonLexer
import util
class _match(object):
def __init__(self, root, cwd, files, mf, ap):
self._root = root
self._cwd = cwd
self._files = files
self._fmap = dict.fromkeys(files)
self.matchfn = mf
self._anypats = ap
def __call__(self, fn):
return self.matchfn(fn)
def __iter__(self):
for f in self._files:
yield f
def bad(self, f, msg):
return True
def dir(self, f):
pass
def missing(self, f):
pass
def exact(self, f):
return f in self._fmap
def rel(self, f):
return util.pathto(self._root, self._cwd, f)
def files(self):
return self._files
def anypats(self):
return self._anypats
class always(_match):
def __init__(self, root, cwd):
_match.__init__(self, root, cwd, [], lambda f: True, False)
class never(_match):
def __init__(self, root, cwd):
_match.__init__(self, root, cwd, [], lambda f: False, False)
class exact(_match):
def __init__(self, root, cwd, files):
_match.__init__(self, root, cwd, files, lambda f: f in files, False)
class match(_match):
def __init__(self, root, cwd, patterns, include, exclude, default):
f, mf, ap = util.matcher(root, cwd, patterns, include, exclude,
None, default)
_match.__init__(self, root, cwd, f, mf, ap)